Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Codelite and SFML  (Read 16244 times)

0 Members and 2 Guests are viewing this topic.

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Codelite and SFML
« Reply #15 on: March 13, 2016, 10:29:53 pm »
Okay, I just watched a video that really helped me (). I made the Workspace file and opened it up with Codelite. I built the project/workspace and it ran fine, but when I went to look for the libs in the lib folder, they weren't there. Do I need these lib files? When I opened up the workspace it had all of the header and cpp files there, but I'm not sure where the libs are. Any help with this?

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Codelite and SFML
« Reply #16 on: March 14, 2016, 10:44:42 pm »
Do I need to make a new project in the workspace??

Any help? :-\

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Codelite and SFML
« Reply #17 on: March 15, 2016, 05:15:02 am »
Well, I decided to build SFML in Cmake for Code::Blocks (I have that IDE but would rather use Codelite). I got everything to work, I built the files I compiled it, I got the lib files. But now when I try out a project from the examples folder, I get all of these errors...
Build log:

-------------- Build: Debug in TrophyHunter (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -L"C:\sfml build\lib" -o bin\Debug\TrophyHunter.exe obj\Debug\main.o   -lsfml-window-s -lsfml-graphics-s -lsfml-audio-s -lsfml-main -lsfml-system-s
obj\Debug\main.o: In function `main':
C:/Projects/TrophyHunter/main.cpp:27: undefined reference to `glClearDepth@8'

C:/Projects/TrophyHunter/main.cpp:28: undefined reference to `glClearColor@16'
C:/Projects/TrophyHunter/main.cpp:31: undefined reference to `glEnable@4'

C:/Projects/TrophyHunter/main.cpp:32: undefined reference to `glDepthMask@4'
C:/Projects/TrophyHunter/main.cpp:35: undefined reference to `glDisable@4'

C:/Projects/TrophyHunter/main.cpp:36: undefined reference to `glDisable@4'
C:/Projects/TrophyHunter/main.cpp:39: undefined reference to `glViewport@16'

C:/Projects/TrophyHunter/main.cpp:42: undefined reference to `glMatrixMode@4'
C:/Projects/TrophyHunter/main.cpp:43: undefined reference to `glLoadIdentity@0'

C:/Projects/TrophyHunter/main.cpp:45: undefined reference to `glFrustum@48'
C:/Projects/TrophyHunter/main.cpp:95: undefined reference to `glEnableClientState@4'

C:/Projects/TrophyHunter/main.cpp:96: undefined reference to `glEnableClientState@4'
C:/Projects/TrophyHunter/main.cpp:97: undefined reference to `glVertexPointer@16'

C:/Projects/TrophyHunter/main.cpp:98: undefined reference to `glColorPointer@16'
C:/Projects/TrophyHunter/main.cpp:101: undefined reference to `glDisableClientState@4'

C:/Projects/TrophyHunter/main.cpp:102: undefined reference to `glDisableClientState@4'
C:/Projects/TrophyHunter/main.cpp:124: undefined reference to `glViewport@16'

C:/Projects/TrophyHunter/main.cpp:128: undefined reference to `glClear@4'
C:/Projects/TrophyHunter/main.cpp:131: undefined reference to `glMatrixMode@4'

C:/Projects/TrophyHunter/main.cpp:132: undefined reference to `glLoadIdentity@0'
C:/Projects/TrophyHunter/main.cpp:133: undefined reference to `glTranslatef@12'

C:/Projects/TrophyHunter/main.cpp:134: undefined reference to `glRotatef@16'
C:/Projects/TrophyHunter/main.cpp:135: undefined reference to `glRotatef@16'

C:/Projects/TrophyHunter/main.cpp:136: undefined reference to `glRotatef@16'
C:/Projects/TrophyHunter/main.cpp:139: undefined reference to `glDrawArrays@12'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x205): undefined reference to `glGetString@4'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x216): undefined reference to `glGetString@4'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0xf33): undefined reference to `glGetIntegerv@8'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0xf49): undefined reference to `glGetIntegerv@8'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0xf51): undefined reference to `glGetError@0'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0xf96): undefined reference to `glEnable@4'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0xfcd): undefined reference to `glGetIntegerv@8'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x100e): undefined reference to `glGetIntegerv@8'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x104f): undefined reference to `glGetString@4'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x10fe): undefined reference to `glGetIntegerv@8'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x19d3): undefined reference to `glGetIntegerv@8'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x19f0): undefined reference to `glGetIntegerv@8'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x19f8): undefined reference to `glGetError@0'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x1a5f): undefined reference to `glEnable@4'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x1a8d): undefined reference to `glGetIntegerv@8'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x1ad2): undefined reference to `glGetIntegerv@8'

C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x1b0f): undefined reference to `glGetString@4'
C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj):GlContext.cpp:(.text+0x1bb9): undefined reference to `glGetIntegerv@8'

C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../../mingw32/bin/ld.exe: C:\sfml build\lib/libsfml-window-s.a(GlContext.cpp.obj): bad reloc address 0x5d in section `.text$_ZNSt8_Rb_treeIPN2sf4priv9GlContextES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE16_M_insert_uniqueERKS3_[__ZNSt8_Rb_treeIPN2sf4priv9GlContextES3_St9_IdentityIS3_ESt4lessIS3_ESaIS3_EE16_M_insert_uniqueERKS3_]'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 3 second(s))
44 error(s), 0 warning(s) (0 minute(s), 3 second(s))
 

I "think" it has to do with the opengl due to the undefined references starting with gl..

If any of you out there know how to fix this I would be very, very happy!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Codelite and SFML
« Reply #18 on: March 15, 2016, 07:46:02 am »
Check the latest official tutorial. You need to link SFML's dependencies, when.linking statically.

You also need to link the debug libraries in debug mode (-s-d) suffix.
« Last Edit: March 15, 2016, 10:47:13 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Codelite and SFML
« Reply #19 on: March 15, 2016, 10:29:43 am »
Slight typo BTW eXpl0it3r meant -s-d, not -s-f.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Codelite and SFML
« Reply #20 on: March 15, 2016, 10:47:33 am »
Woops, thanks! :D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Codelite and SFML
« Reply #21 on: March 15, 2016, 06:50:32 pm »
I have been watching this thread and still have a hard time seeing how this is causing you a problem, so I redid my usual steps and am typing out how I do it.  This assumes you already have cmake and a git client installed on your machine, and in your path variable.  Omit steps you see as superfluous.  Also note that this is on windows so the '/' is used instead of'\', but both work.

First, I make a folder named Repositories.  Inside Repositories I make a GIT folder(I use other source control types so this just puts them all in one place for me.).  Open the git folder and on any white space(where files would normally be listed) hit control-shift and right click(on white space).  Click 'Open command window here' from the context menu that pops up.  Now type 'git clone https://github.com/SFML/SFML.git' and let it finish.  If git is not in your path then, in the command window, type 'set PATH=%PATH%;your_git_folder/bin' and try cloning again.

Second, open cmake-gui.  If cmake-gui is not in your path then type  'set PATH=%PATH%;your_cmake-install_folder/bin' and then run 'cmake-gui'.In the 'Where is the source code:' field browse to where you cloned SFML.  For me that is 'D:/Repositories/GIT/SFML'.  Now copy that and put it in the 'Where to build the
binaries:' field and add to the end of it '/build'.  Click configure and it will ask you if you want to create the build directory.  Click yes.  Now a selection window comes up to ask you which generator to create for the project.  There really is no need to choose 'Codelite' or 'Codeblocks',  just choose 'MinGW makefiles'.  Those will work for your TDM install and click 'Finish'.  Cmake will then check and be sure it can find everything.  Your TDM install /bin dir needs to be in your path.  If it is not, close cmake and in the command window put 'set PATH=%PATH%;your_TDM-install_folder/bin' then run cmake-gui again.

Third, set the 'CMAKE_INSTALL_PREFIX' to your build folder path you set above and add on '/bin'.  All this does is copy all the binaries/headers to the 'bin' folder so you can locate them easier.  Then, hit configure again and then 'Generate'.  This, at default, will build the release libraries and put them in the 'bin' folder you set for 'CMAKE_INSTALL_PREFIX'.  Go to your build folder and type 'mingw32-make' and the build process should begin.  You can type 'mingw32-make -j' to use as many threads as your cpu supports to build, but for some things that causes compile problems so I just leave off '-j' by habbit to avoid errors.  Once that is finished, type 'mingw32-make install'.  This will copy all the binaries to the 'bin' folder.  Now go one by one in creating the other library types (debug/static).  All of them will be found in the bin folder.

Now you can load up Codelite, start a project, set all your lib paths, and it should all work.

This is just how I do it.  Others do it differently, but the end results are the same.

Also take not of what eXploit3r wrote.  Static builds have more lib requirements.

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Codelite and SFML
« Reply #22 on: March 16, 2016, 03:25:17 am »
Spirro, Thank You so much!

You're post has worked so far! I have one part that I do not quite know how to do:
Quote
  Now go one by one in creating the other library types (debug/static).

I believe I have followed all the way to there, but I'm not sure how to do that..

Side question:
Inside of my build folder should I have my "lib ... .a" as well as the "sfml- ... -2.dll" and in the bin folder just have the "sfml- ... -2.dll"?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: Codelite and SFML
« Reply #23 on: March 16, 2016, 07:44:27 am »
Change the settings in CMake. For debug builds change the "Release" string to "Debug".

It's highly recommended to run make install, that way everything needed will be copied nicely.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Codelite and SFML
« Reply #24 on: March 16, 2016, 07:53:53 pm »
can you elaborate just a little bit? I don't want to screw up now.. ;)

I know how to do the release and debug part, but do I leave the "Where the source code is:" and the "Where to build the binaries:" the same?

And umm,

Quote
It's highly recommended to run make install, that way everything needed will be copied nicely.

What exactly does this mean?

sorry if I am asking dumb questions, I just want to finish this already.

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Codelite and SFML
« Reply #25 on: March 16, 2016, 08:59:46 pm »
I have one part that I do not quite know how to do:
Quote
  Now go one by one in creating the other library types (debug/static).

I believe I have followed all the way to there, but I'm not sure how to do that..

Side question:
Inside of my build folder should I have my "lib ... .a" as well as the "sfml- ... -2.dll" and in the bin folder just have the "sfml- ... -2.dll"?

Creating the other library types is easy.  You have already set things up.  If you first made the release build, then after typing 'make install' on your command line, go back to cmake-gui and uncheck the box for 'BUILD_SHARED_LIBS', hit 'Configure' then 'Generate' and go back to the command line then  'make' and 'make install' again. That will create the static release libraries.  Then as Exploit3r said, change 'Release' to 'Debug' and repeat the steps you did for BOTH release builds.  The shared and static libs.

By using 'make install' what happens is all the binaries/includes will be copied to the folder you specified in cmake.  That just makes it much easier for you to find them.  Set them up how you want.  Leave them as is, move them and setup a directory structure easier for you to link with or configure in Codelite.  Doesn't matter.  The only things you are concerned about after the process is finished is where the binaries and includes are so you can configure linking for your compiler install.  Leave them there or move them.  Doesn't matter. 

After the compilation of SFML, the source of SFML is no longer needed.  You can ignore it and leave it there or delete it.  Just don't delete your binaries or you have to clone the repository again and rebuild it.

For the '.a' and '.dll' files I normally just dump them all in the same folder so that when I set up an IDE I only have to remember one directory for the library I am using.  Make your own preffered method of use and do it.  It's that simple.

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Codelite and SFML
« Reply #26 on: March 16, 2016, 11:06:22 pm »
I have everything built now! Stay with me here as I am going to ask a series of possibly useless questions:

Does this mean that sfml is compiled?
Do I need to start a project and link the libs and add the include path?
When adding in the libs I know there is a certain order, does this apply with the debug libs as well?

Thanks

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Codelite and SFML
« Reply #27 on: March 16, 2016, 11:28:02 pm »
I have everything built now! Stay with me here as I am going to ask a series of possibly useless questions:

Does this mean that sfml is compiled?
If you made 4 passes then yes.  You have Release, Release static, Debug, Debug static

Quote
Do I need to start a project and link the libs and add the include path?
Yes.  Look at the documentation of your development environment to know how/where to plug in the locations of the SFML or other libs you are using for your project so it can find and use them.

Quote
When adding in the libs I know there is a certain order, does this apply with the debug libs as well?
Yes, both debug and release will use the same order to build using G++ and derivatives(that includes TDM).

And again, you appear to be doing a static build so look at this page http://www.sfml-dev.org/tutorials/2.3/start-cb.php near the bottom where it lists the dependencies of each of the SFML libraries.  When you cloned SFML from GIT you got those dependencies in the 'extlibs' folder.  Look there for what your environment complains about not finding.

lane

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Codelite and SFML
« Reply #28 on: March 17, 2016, 01:04:39 am »
 >:( I am feeling dumber every minute!

I went to go link up my libs and includes and I even added the SFML_STATIC macro, but no luck.

This is how I have it set up.

Include path: C:/Repositories/GIT2/build/bin/include
Library path: C:/Repositories/GIT2/build/lib
Libraries: sfml-graphics-s-d;sfml-graphics-s;sfml-window-s-d;sfml-window-s;sfml-audio-s-d;sfml-audio-s;sfml-network-s-d;sfml-system-s;sfml-system-s-d

I keep getting errors about the graphics..

Spirro

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: Codelite and SFML
« Reply #29 on: March 17, 2016, 01:19:44 am »
Libraries: sfml-graphics-s-d;sfml-graphics-s;sfml-window-s-d;sfml-window-s;sfml-audio-s-d;sfml-audio-s;sfml-network-s-d;sfml-system-s;sfml-system-s-d

I keep getting errors about the graphics..

Release and debug builds use different versions of libraries.  I don't know which you are trying to do, release or debug, but you are including both sets of libs.  If you are doing a release build you only use the libs with the -s extension.  For debug use the -s-d files.

You also did not include what those SFML libraries require as dependencies.   Look at the page I linked above.  You are using sfml-graphics-s-d, the static debug link library.  On the sited page it lists that SFML module needs opengl32, freetype, and jpeg.  So add those after sfml-graphics-s-d in your include list.  Then for the other sfml modules do the same.  Find out their dependencies from that list and add them if they are not already added by you.

Now IF you include the right sfml libs in order(as listed on the above linked page) with their dependencies(again, listed on the above page) in order, and have SFML_STATIC listed where it needs to be in the CodeLite IDE it will compile.

Just keep playing with it.

 

anything