Search code examples
csfml

undefined reference to _imp_sfBlendAlpha


I have recently installed MinGW and CSFML on my laptop and I run:

gcc shaders.c -csfml-system -csfml-graphics

I get an error:

...\ccV1NsAK.o:shaders.c:(.text+0x247):' undefined reference to _imp__sfBlendAlpha'

How do I fix this?
Kind Regards, Boston Brooks.


Update 1
I've played around with installing to different search paths but I couldn't get this to work. I reinstalled MinGW and pasted the files from the CSFML package to the default path. Now I get:

gcc shaders.c -lcsfml-system -lcsfml-window -lcsfml-graphics
C:\Users\bbroo\AppData\Local\Temp\cc9QM4Nx.o:shaders.c:(.text+0x2d8): undefined reference to '_imp__sfBlendAlpha'
C:\Users\bbroo\AppData\Local\Temp\cc9QM4Nx.o:shaders.c:(.text+0x318): undefined reference to '_imp__sfTransform_Identity'
collect2.exe: error: ld returned 1 exit status

Update 2
I copied CSFML to my home folder. I get:

$ gcc -B ~/CSFML -Ld: ~/CSFML shaders.c  -lcsfml-system -lcsfml-window -lcsfml-graphics
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find C:/MinGW/msys/1.0/home/bbroo/CSFML: Permission denied
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lcsfml-system
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lcsfml-window
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lcsfml-graphics
collect2.exe: error: ld returned 1 exit status

The header files can be accessed but the dot-a files are 'permission denied' How do I set the permissions to Read-Write-Execute for all users on all files in CSFML using MSYS?

Same problem if I use C:\SFML


Update 3
When I unzip the files to the default path, a sub-folder is generated in the folder where my dot-a files are located. It contains several dot-a files, and a readme text file.

This README file is copied into the directory for GCC-only header files when fixincludes is run by the makefile for GCC:

Many of the files in this directory were automatically edited from the standard system header files by the fixincludes process. They are system-specific, and will not work on any other kind of system. They are also not part of GCC. The reason we have to do this is because GCC requires ANSI C headers and many vendors supply ANSI-incompatible headers.

Because this is an automated process, sometimes headers get "fixed" that do not, strictly speaking, need a fix. As long as nothing is broken by the process, it is just an unfortunate collateral inconvenience. We would like to rectify it, if it is not "too inconvenient".


Update 4
Compiling without linking worked fine but linking separately didn't work:

bbroo@DESKTOP-1F1J3SM ~/Shaders
$ ld shaders.o libcsfml-system.a libcsfml-window.a libcsfml-graphics.a
shaders.o:shaders.c:(.text+0x10): undefined reference to `__main'
shaders.o:shaders.c:(.text+0x2d8): undefined reference to `_imp__sfBlendAlpha'
shaders.o:shaders.c:(.text+0x318): undefined reference to `_imp__sfTransform_Identity'
shaders.o:shaders.c:(.text+0x4bc): undefined reference to `sleep'

Update 5
Now I get:

bbroo@DESKTOP-1F1J3SM ~/Shaders
$ ld shaders.o libcsfml-system.a libcsfml-window.a libcsfml-graphics.a csfml-system-2.dll csfml-window-2.dll csfml-graphics-2.dll
shaders.o:shaders.c:(.text+0x10): undefined reference to `__main'
shaders.o:shaders.c:(.text+0x4bc): undefined reference to `sleep'

Solution

  • gcc shaders.c libcsfml-system.a libcsfml-window.a libcsfml-graphics.a csfml-system-2.dll csfml-window-2.dll csfml-graphics-2.dll

    it works for me.