#Raylib in VS

29 messages · Page 1 of 1 (latest)

soft dawn
#

hi guys i tried to connect raylib to vs and the library is fine, but when i tried to run the code 2 error jums out

orchid sphinxBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

soft dawn
#

yes

patent hill
#

also if you are using cmake please send the cmake script too

soft dawn
#

The main element is already defined in the losowegowno.obj element

soft dawn
#

at least one multiply defined symbol was found

patent hill
#

so did u use headerguards or did u include a header multiple times?

soft dawn
#

no i have only one void main

patent hill
#

can u sendcode for the main function?
Because the main function cannot be void?

soft dawn
#

#include "raylib.h"

int main(void)
{

const int screenWidth = 800;
const int screenHeight = 450;

InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");

SetTargetFPS(60);
while (!WindowShouldClose())
{

    BeginDrawing();

    ClearBackground(RAYWHITE);

    DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);

    EndDrawing();
    
}
CloseWindow();
return 0;

}

#

this is the whole code

patent hill
#

so the code seems to be correct
can u send the compile output soemthing like this for example

x.cpp:1:1: error: ‘::main’ must returnint1 | void main() {}
      | ^~~~
soft dawn
#

wait im new to vs where to find it?

patent hill
#

so how do u compile your project
if u click the button like the compile button u can find the output in the output page
or in the problems tab

soft dawn
#

okej so let me translate it becouse it in polish

#

Compilation started at 12:18...
1>------ Compilation started: Project: randomwno, Configuration: Debug x64 ------
1>randomowegowno.cpp
1>main.cpp
1>Generating code...
1>main.obj : error LNK2005: Member main is already defined in member randomwno.obj
1>LINK : warning LNK4098: The default library "MSVCRT" conflicts with other libraries; use /NODEFAULTLIB:library
1>C:\Users\48721\Desktop\randomowegowno\x64\Debug\randomowegowno.exe : fatal error LNK1169: At least one multiply defined symbol found
1>Compiling project "randomowegowno.vcxproj" - FAILED. ========== Build: Success - 0, Failure - 1, Current - 0, Skipped - 0 ==========
========== Build - Completed at 12:18. Duration: 12.439 sec ==========

patent hill
#

so for your information the other cpp file named randomowegowno.cpp is also being compiled and both contradict on the main function
So you can like move it to another folder or you can remove it from compiling
randomwno is a TU which defines the main function. And also the main.cpp is a TU which defined the main function. these two contradict because there needs to be one unique deceleration of the main function. meaning you have to remove it from compilation and linking or you can remove the main function (comment it even) from the file to let the project compile

soft dawn
#

bro...

#

you are genious

#

thank you very much

patent hill
#

thanks

soft dawn
#

i tried this for days

#

and didnt work

patent hill
#

you can mark this question as solved by doing !solved

patent hill
soft dawn
#

!solved