c++ SDL2 - ld||cannot find -lmingw32| - c++

I was creating program on windows with SDL2 and the program worked fine, but when I changed my os to linux mint (and install code::blocks, gcc, g++, SDL2), I run into troubles with compiling my code.
I have one error:
- ld||cannot find -lmingw32|
I guess that I don't have mingw32 library, where can I get it? Or is the problem diferent?
BTW: I also tryed to google it.
Thank for response.

Read the manual.
On linux you don't need -lmingw32. Instead, use
`sdl2-config --libs`
to get the list of all needed linker flags.
Example usage:
gcc -o myprogram myprogram.o `sdl2-config --libs`

Problem was solved by removing linker on mingw32 and lib rotozoom.h.

Related

Error loading SDL2 shared libraries while executing program on another pc

I'm trying to compile a program i made using SDL2 to work on others computers (or testing VM in this case).
I've been compiling it with what i think are the correct flags, e.g. g++ main.cpp -o main -lSDL2, however when i try executing it on another Ubuntu installation i get this error.
error while loading shared libraries: libSDL2-2.0.so.0: cannot open shared object file: No such file or directory
From my understanding it's not a problem in my compiling but with how i expect it to work on another Linux installation; I've cross-compiled (using mingw32) and tested it (using a freshly installed VM) on Windows adding the correct dlls with the exe (seems to work fine) and I was expecting for it to work in a similar fashion.
What's the standard in this cases? Should i write a setup scripts to install the library dependencies on the target machine? Is there another way I'm not aware of? I've never released an application for Linux (nor Windows) and I'm struggling to find the resources to do things "the right way".
Thanks for everyone suggestions, I ended up settling for the easy way, compiling the "easy to install" libraries dynamically e.g.-lSDL2 and the others statically (checked the licenses and it should be fine) like so:
g++ main.cpp -o main -Wl,-Bdynamic -lSDL2 -lSDL2_image -lSDL2_ttf -Wl,-Bstatic -lSDL2_gfx -static-libgcc -static-libstdc++
I'll put in my documentation how to install the required SDL2 libraries.
I am not sure how familiar you are with pkg-config, but the output for sdl2 is this:
-D_REENTRANT -I/usr/include/SDL2 -lSDL2
This was found from running this:
pkg-config --cflags --libs sdl2
Basically, you need to point to where SDL2 is located BEFORE you actually link to it.
The tool pkg-config is designed to tell you the information you need when you want to link to a package in Linux. You were linking with the library, but you forgot to tell GCC where the library is located.
If you want to compile you code, try this:
g++ main.cpp -o runme `pkg-config --cflags --libs sdl2`
This will automatically grab all of the flags that you need to compile with SDL2 included.
Oh, and you should note, ORDER MATTERS WHEN ADDING FLAGS AND LIBRARIES!!!
There are many questions on SO where the order of compiler options caused all of the problems. Do not be like those people. I suggest you search SO for more info on that.

Sysgcc: ld.exe cannot find -lcurl -ljsoncpp

I'm working on a project on a Raspberry Pi 2 Model B. I started coding and compiling directly on the Pi and now I want to work on a Windows 7 PC. I already installed the SysGCC Cross-Compiler and managed to compile a simple Hello-World program.
Problem is, for my Project i use curl and jsoncpp. Natively on the Raspberry i have no problems compiling it, but the cross-compiler on Windows gives me following error:
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lcurl
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -ljsoncpp
I don't use a makefile or so because i never really worked with that and on the raspi it just worked fine with this command:
g++ ../src/rpi/main.cpp ../src/rpi/connection.cpp ../src/rpi/jsonparser.cpp ../src/rpi/idchecker.cpp ../src/rpi/eventoperator.cpp -o ../bin/main -lcurl -ljsoncpp
On the Windows system i tried it with a command like this:
arm-linux-gnueabihf-g++.exe -std=c++11 ../src/rpi/main.cpp ../src/rpi/connection.cpp ../src/rpi/jsonparser.cpp ../src/rpi/idchecker.cpp ../src/rpi/eventoperator.cpp -o ../bin/main -L"C:/SysGCC/raspberry/arm-linux-gnueabihf/sysroot/usr/include/jsoncpp/json/" -L"C:/SysGCC/raspberry/arm-linux-gnueabihf/sysroot/usr/include/arm-linux-gnueabihf/curl/" -lcurl -ljsoncpp
So i read that i have to tell the compiler/linker where the libraries are, but i don't really understand why since it works perfectly without the -L flag on the Raspi. I think i put the libraries in the same folder as on the Raspi, so i don't understand why they are not found. I hope someone can help me ore give me some short basic explanation on how this stuff works, cause i don't find any working tutorial or other helpful questions for my problem.
On raspberry-pi the libraries are most likely to be linked from system directory like /usr/lib or /usr/local/lib. On Windows, you need to specify the correct path(s) with -L flag.

OpenBlas and g++

I have installed OpenBlas in TX1 and the time_dgemm example compiles fine with the gcc. However, I need to be able to link the rest of my code with OpenBlas using g++. When I try to compile the time_dgemm example with g++ it fails, giving the linking error "...undefined reference to 'dgemm_(......". The only change is using the g++ instead of gcc.
I have tried to compile the OpenBLAS library with g++ (make CC=g++), as other people suggested in the past, but the compilation fails when it tries to compile some part of BLAS.
Any ideas?
If some people have the same issue, I was able to compile with the following command:
g++ openBlasExample.cpp -I /usr/include/openblas -lopenblas
You can find your openblas include folder by using on Linux:
locate openblas
More info here:
https://gist.github.com/xianyi/6930656

GCC Fails to Generate Object Files When Compiling

Recently I have noticed that GCC does not generate object (*.o) files when compiling with '-c'. It does not issue any errors or warnings. I have run it with '-verbose' but it shows nothing out of the ordinary.
Running under Windows:
gcc -Wall -c source_file.c
I have also tried compiling with '-verbose' to display detailed information
gcc -Wall -verbose -c source_file.c
It should produce 'source_file.o' but it doesn't. Any idea what's going on?
The issue has been resolved. Reinstalling GCC (mingw) fixed the problem. It is possible the problem came about because I tried to install the 64-bit version of GCC (Mingw-w64) to top of the 32-bit version...

Linking the Allegro library to a C++ application using the g++ compiler (Ubuntu)

In trying to get Allegro (A C++ game programming library) to work with a very simple C++ application in Ubuntu 12.04, I am unable to get the program to compile with the allegro header definitions. It returns the error allegro.h - no such file or directory found. I tried running a pkg-config to find the proper linker command, but that didn't help in compilation.
I am almost certain it is installed correctly at this point. I tried using a pkg-config --cflags --libs allegro-5.0 for the include file paths, none of which worked when using in the g++ compile line.
Thanks in advance.
Running a pkg-config --cflags --libs allegro-5.0 told me wrong on the include path. It told me to use -I/usr/local/include and after some digging into that folder, I found that the include path is -I/usr/local/include/allegro5 instead. It is compiling fine now.