SDL2 - cannot find lsdlmain and lsdl. Codeblocks - c++

I just started fooling around with SDL2 using Lazy Foo's tutorial and I'm having some issues. When building I get two errors:
cannot find lsdl
cannot find lsdlmain
Now... of course it can't find those because they are not in the lib folder I linked. I only have lsdl2main and lsdl2. I put the SDL2.dll in my project folder and did everything as Lazy Foo said, yet I still have this issue. I did manage to bypass this issue by copying the lsdl2 and lsdl2main from the lib folder and changing them to lsdl and lsdlmain. Now I have both lsdl/lsdlmain and lsdl2/lsdlmain ... even though they are the same libraries. I don't think this is ok, this is why I'm asking the question. What is the proper way to solve this? I read on lazy foo something about the compiler picking 32-bit libs over 64-bit , but I am using the 32-bit ones from the 32-bit folder, so I'm not sure if that is an issue.

The proper way is just use sdl2main and sdl2 instead of obsolete sdlmain and sdl in your linker options. Lazy Foo's tutorials are obsolete and obviously require some corrections if you intend to use SDL2 instead of SDL 1.x which is the version tutorials are based on.

This question is a year old but I hope this still helps someone struggling to find an answer. If you were following Lazy Foo's tutorial "setting up SDL" on Code Blocks, you might have accidentally opened his old tutorial via Google. http://lazyfoo.net/SDL_tutorials/ instead of http://lazyfoo.net/tutorials/SDL/ which has the updated instructions.
His old one shows that you have to fill out -lsdl and -lsdlmain on the Global Compiler's linker which is under Settings> Compiler.. > Linker Settings. Then you somehow opened his new tutorial which shows you to to fill -lSDL2main -lSDL2 under the Build option's linker.
Just check if your Global Compiler's linker or your Build Option's linker settings are correct. Setting -lSDL2main -lSDL2 flags on either one should work.

Related

Cannot find -lfreetype (SFML static linking)

I'm trying to statically link SFML, which requires linking all other dependencies. On the SFML tutorial page it states that all dependencies are provided along side it, but I genuinly couldn't figure out any way to link them. Other dependencies seem to work just fine (or they just don't produce linker errors yet). I also tried manually downloading freetype, building it, but that just left me in a bigger mess of files, and as a beginner, I really can't follow anything what's going on. My "Link libraries" look like this:
And I tried putting the directory of the header files (I could only find the header files, nothing else, no .a or .so files, not sure if that's the problem) in various places in the search directories.
Closest thing to my problem I found was this, but I really couldn't get anything out of this...
P.S. I'm on Windows, using Code::Blocks, GCC 7.3.0, custom built SFML with CMake for my compiler aswell. Unless I missed something in tutorials, I don't think I missed anything. Without static linking, everything worked fine. I didn't forget SFML_STATIC in #defines either. I don't know what else to add, if there is something missing, please tell me.
I'm at a loss for a couple of days here, any help would be appreciated, even if it's some harsh critique because of missing a simple detail :P
The solution to this specific problem for me was simply rebuilding SFML with CMake again, because for some reason the install path (Program Files x86\SFML\..) wasn't actually created, and that's where all the .a files were. Including those in the search directories fixed the cannot find -lfreetype problem.

BOOST & GCC, undefined reference to boost

I must say, I'm new to using Boost libs, but I have used them for a few of my projects, and have been super pleased with them.
Now, I would like to get all files with certain extension in one of my folders, so, looking it up online, I found this>How to get list of files with a specific extension in a given folder
I'm using Code Blocks on Windows 7.
I have done everything it seemed required, and when I try to compile it, I get three errors>
C:\boost_1_58_0\boost\system\error_code.hpp|221|undefined reference to
boost::system::generic_category()'|
C:\boost_1_58_0\boost\system\error_code.hpp|222|undefined reference to
boost::system::generic_category()'|
C:\boost_1_58_0\boost\system\error_code.hpp|223|undefined reference to
`boost::system::system_category()'|
I was looking it up online, and found that, besides pointing my "Search directories (compiler and linker) to boost installation, I need to point it directly to boost system lib somehow.
I tried -lboost_system in my Linker settings, but that didn't solve it.
I'm hardly an expert here, so I'm asking you guys if you can help me.
Does anyone have any ideas?
You need to provide the path where your lib is with the -L option of GCC.
Check this section of Boost documentation

OpenGL Red Book example 1-1 error LNK2019; Problems with GLUT and GLEW, as well as many default libs

I got the Red book to expand my currently small knowledge on OpenGL, but the first tutorial is giving me nightmarish problems. You've seen a few of these, I know, but I've got LoadShaders.cpp pointed to and /NODEFAULTLIB set to yes in the project settings, and it has all come down to this last bunch of errors, all or most LNK2019's.
http://pastebin.com/2tTUtiUc Is where you can see the errors. I don't know if I should paste the code here, as you may have already seen it.
One more thing, I tried what the other posters said resolved it for them, but it doesn't resolve it for me.
You should post less complain and more details, so others can do more to help. LNK2019 usually means you are having problem with the linking phase. problems might be:
did you put the .lib file under link path? can linkers find them?
linking parameter details , could it be related with:
one of the third-party libraries was not set to /MT in release (but it was /MTd in debug) - changing that flag made it all work.
lastly, working directly from working examples instead of set them up all yourselves.
start from Working Excample, get code directly there.
OK, this is wierd to me, but pointing the linker to glew32.lib and freeglut.lib and disabling libcmtd.lib seemed to fix the problem. After that, I can build it with no problem. So, just to repeat, Additional dependencies is set to only glew32.lib and freeglut.lib, and ignore default libraries is set to no, and ignore libcmtd.lib.

Issues with linking library C++

My problem is I am not able to include a library into my current project. [The way to include a library in netbeans into a project is to link it via linker to the project]. However, in my current project(which is written by another programmer who left the organization) the option of linker is not appearing. I have attached a screenshot. I am faced with the issue that the option of linking the library via linker to my current project is not appearing in IDE. Can someone please please help me out. I'll be highly thankful to you for the same.
Please guide me as to how should I link the library to my project. I have really spent a lot of days doing it but I did not succeed.
Assuming you are only interesting in libspatialindex:
Make sure you have the appropriate files installed: try a locate libspatialindex and see where it is installed. You could have a *.a, *.so or similar extension. Note the path.
Go into your project root directory, i.e: /home/keira/netbeans/projects/myproject
Try: gcc -i main.cpp -L/usr/lib/ -lspatialindex -o myfile
Replace the -L/usr/lib with the actual location where you know the library is at.
The cxx link flag is usually the name of the library with an -l prefix. If for example the name found in the system is libspatialindex.so then its a good bet to try with -lspatialindex.
There is a way to find the actual flags on Debian & Ubuntu systems but I cannot atm remember it. Alternatively you can always look on google or read the library documentation.
When you usually see linker errors with undefined functions, etc, it means you're not linking, provided you have included the headers and they are found.
Now for Netbeans, I assume there is the option of passing extra arguments to the compiler. In this case, all you need is the -lspatialindex flag, provided Netbeans knows where to find the library and the headers. That is how it works in KDevelop and other IDE's I have used.
Alternatively if you want more control and more automation, you may want use a tool like cmake.

Tool Chain for WxWidgets explained

Where can I find an writeup that shows me how to set up a tool chain for WxWidgets (C++) on linux/ubunto and/or OS X.
I downloaded, compiled & installed WxWidgets both on linux and OS X, compiled and tried the samples, but seem to be stuck setting up a compile environment in my own home directory.
DialogBlocks from http://www.dialogblocks.com looked promising, but it insists on recompiling WxWidgets again and again .. must be something about it I don't understand.
Writing code from scratch seems to fail due to a lack of paths to libraries, tools or whatnot .. again a lack og understanding on my part, I am sure.
So, can anyone point me to a tool chain setup, that has more than the bare minimum of instructions and fills in some of the "why" instead of only the minimal "what".
Like all C/C++ programs, the compiler has to know in what directories to look for include files, and the linker has to know what libraries it should link to.
The WxWidgets package, if installed correctly, includes the program wx-config. This can be used while compiling and linking, like so:
g++ $(wx-config --cxxflags) -c my_prog.cpp
g++ my_prog.o $(wx-config --libs) -o my_prog
I've found these two pages to be of help when setting up wxWidgets for Eclipse and MinGW.