Load PNG with SDLImage in Vala - sdl

RWops enemy_rwops = new RWops.from_file("img/enemy.png", "rb");
enemy = SDLImage.load_png(enemy_rwops);
I have that code to load a .png (enemy is a SDL_Surface). However, I get this error:
/tmp/ccGDtjkw.o: In function `':
main.vala.c:(.text+0x59): undefined reference to `IMG_LoadPNG_RW'
collect2: error: ld returned 1 exit status
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)
Those two lines are in my constructor, and I am, indeed "using SDLImage" and adding it in the "--pkg" compile line:
valac --pkg sdl --pkg sdl-gfx --pkg sdl-image -X -lSDL_gfx -o mission- main.vala
Any ideas?

valac --pkg sdl --pkg sdl-gfx --pkg sdl-image -X -lSDL_gfx -X -lSDL_image --Xcc=-I/usr/include/SDL -o game main.vala
Got it, just use that compile line.

Related

Compile a fortran 77 file(MIAH.f77) gfortran

I am trying to compile a .f77 file. Here is the command:
gfortran MIAH.f77 -o test
but I am getting the message below:
/usr/bin/ld:MIAH.f77: file format not recognized; treating as linker script
/usr/bin/ld:MIAH.f77:1: syntax error
collect2: error: ld returned 1 exit status**
What does this mean?

error: ld returned 1 exit status - codeblocks

I downloaded the source of a small openGL project but when i try to compile it gives me this error message ("error: ld returned 1 exit status") and i dont know how to fix it. Does anyone know what it means?
The program uses openGL with GLFW 2.
Here's the build log:
-------------- Build: Debug in Procedurus (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -L"C:\Program Files (x86)\CodeBlocks\MinGW\lib" -L"C:\Program Files (x86)\CodeBlocks\MinGW\lib" -o bin\Debug\Procedurus.exe obj\Debug\Application\TextTool.o obj\Debug\Geometry\AstronomicalObject.o obj\Debug\Geometry\Atmosphere.o obj\Debug\Geometry\CloudLayer.o obj\Debug\Geometry\Frustum.o obj\Debug\Geometry\Geometry.o obj\Debug\Geometry\Particle2D.o obj\Debug\Geometry\Planet.o obj\Debug\Geometry\PlanetRing.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrain.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrainFace.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrainNode.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrainPatch.o obj\Debug\Geometry\QuadtreeTerrain\QuadtreeTerrainPatchTopology.o obj\Debug\Geometry\QuadtreeTerrain\RidgedMultifractalSphericalQuadtreeTerrain.o obj\Debug\Geometry\QuadtreeTerrain\SphericalQuadtreeTerrain.o obj\Debug\Geometry\SimpleCircle.o obj\Debug\Geometry\SimpleCylinder.o obj\Debug\Geometry\SimpleDisk.o obj\Debug\Geometry\SimpleSphere.o obj\Debug\Geometry\Skybox.o obj\Debug\Geometry\Star.o obj\Debug\Geometry\Starfield.o obj\Debug\GL\GLee.o obj\Debug\Math\Randomizer.o obj\Debug\ProcedurusMain.o obj\Debug\Shaders\ShaderManager.o -lopengl32 -lglfw -lglu32 -lgdi32 -lGLFW GL/glfw
GL/glfw: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
So the problem is with the file named "glfw" but if i delete it and keep only the glfw.h it gives me another error ("mingw32-g++.exe: error: GL/glfw: No such file or directory
")
I can upload the project if that helps.
You have an extra GL/glfw in your compile command, you should delete this, it is not necessary.

"ld" broken (downlevel?) on Linux

I've attempted to build g++ v5.1.0 on my Centos 6 system. The build seems to have worked, but when I try to compile and >link< a program, the linker fails thus:
[seesdev#sees15-lin ~]$ g++ -o testcpp testcpp.cpp
/usr/bin/ld: unrecognized option '-plugin'
/usr/bin/ld: use the --help option for usage information
collect2: error: ld returned 1 exit status
Do I have to get a newer version of "ld"? How?

Error during make: error adding symbols: DSO missing from command line

I am trying to compile some code downloaded from a git repository (OpenNI2, https://github.com/occipital/OpenNI2). I am getting the following errors after running make:
make -C Source/Tools/NiViewer
make[1]: Entering directory `/home/karnivaurus/Data/Libraries/OpenNI2/Source/Tools/NiViewer'
g++ -o ../../../Bin/x64-Release/NiViewer ./../../../Bin/Intermediate/x64-Release/NiViewer/Device.o ./../../../Bin/Intermediate/x64-Release/NiViewer/Draw.o ./../../../Bin/Intermediate/x64-Release/NiViewer/Keyboard.o ./../../../Bin/Intermediate/x64-Release/NiViewer/Menu.o ./../../../Bin/Intermediate/x64-Release/NiViewer/MouseInput.o ./../../../Bin/Intermediate/x64-Release/NiViewer/NiViewer.o ./../../../Bin/Intermediate/x64-Release/NiViewer/Capture.o -L../../../ThirdParty/PSCommon/XnLib/Bin/x64-Release -L../../../Bin/x64-Release -lglut -lGL -lOpenNI2 -lXnLib -Wl,-rpath ./
/usr/bin/ld: ../../../ThirdParty/PSCommon/XnLib/Bin/x64-Release/libXnLib.a(XnLinuxMutex.o): undefined reference to symbol 'pthread_mutexattr_settype##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[1]: *** [../../../Bin/x64-Release/NiViewer] Error 1
make[1]: Leaving directory `/home/karnivaurus/Data/Libraries/OpenNI2/Source/Tools/NiViewer'
make: *** [Source/Tools/NiViewer] Error 2
Any ideas on how I should go about solving this?
You have to add the directive "-lpthread" to your compiler and it is solved.
for instance if your previous code was:
g++ mycode.cpp -o myexecutable
Now you have to put
g++ mycode.cpp -lpthread -o myexecutable
You need add the pthread library into the target_link_libraries. You can edit your CMakeLists.txt file as follow. This solution works for me.
target_link_libraries(ExcutableFileName ${Existed_LIBRARY})
-->
target_link_libraries(ExcutableFileName ${Existed_LIBRARY} pthread)

Boost threads creating InterlockedCompareExchange Errors on mingw32

After googling for InterlockedCompareExchange errors, it seems like it always points to an old error for mingw64, and I am using mingw32.
It seems to happen to all examples that use threads, but if I just have "#include <boost/thread.hpp>" and no calls of a thread it will work, so I think I did the linking correct.
This is my build:
-------------- Build: Debug in UDP_EXAMPLE (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -Wall -D_WIN32_WINNT=0x0501 -g -IC:\boost_1_56_0 -c "C:\Users\poteto\Desktop\Other Programming\UDP_EXAMPLE\server.cpp" -o obj\server.o
In file included from C:\boost_1_56_0/boost/thread/win32/thread_data.hpp:11:0,
from C:\boost_1_56_0/boost/thread/thread_only.hpp:15,
from C:\boost_1_56_0/boost/thread/thread.hpp:12,
from C:\boost_1_56_0/boost/thread.hpp:13,
from C:\Users\poteto\Desktop\Other Programming\UDP_EXAMPLE\server.cpp:5:
C:\boost_1_56_0/boost/thread/win32/thread_primitives.hpp:180:0: warning: ignoring #pragma intrinsic [-Wunknown-pragmas]
mingw32-g++.exe -o Debug\http_server.exe obj\server.o -lws2_32 -lwsock32 C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a C:\boost_1_56_0\stage\lib\libboost_system-mgw47-mt-1_56.a
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x1e): undefined reference to `_InterlockedCompareExchange'
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0x70): undefined reference to `_InterlockedCompareExchange'
C:\boost_1_56_0\stage\lib\libboost_thread-mgw47-mt-1_56.a(thread.o):thread.cpp:(.text$_ZN5boost6detail5win3223GetTickCount64emulationEv+0xb5): undefined reference to `_InterlockedCompareExchange'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 11 second(s))
3 error(s), 1 warning(s) (0 minute(s), 11 second(s))
I linked the libraries: libboost_thread and libboost_system. I am using Codeblocks. Other asio examples without threads work.
In the example:http://www.ce.unipr.it/~medici/udpserver2.html
If I were to remove the call to the thread, it would work.