c - How to compile a dll which needs other dlls -


i'm trying cross compile piece of software i'm doing. i'm on linux , i'm having pretty hard time trying write makefile compiling dll library using sdl2. here it:

#the compiler cc = i686-w64-mingw32-gcc  #the standart ompilation flags of project cflags = -o3 -wall -wno-unused-variable -wno-unused-but-set-variable -wno-implicit-function-declaration  #path folder's root, holy not build framework is. relate makefile prepath = ..  #path sdl, sdl_image , lua includes , libs sdl2includes = -i $(prepath)/sdl2/include sdl2libs = $(prepath)/binaries/4windows/sdl2/64/sdl2.dll sdlimage2includes = -i $(prepath)/sdl2/sdl_image sdlimage2libs = $(prepath)/binaries/4windows/sdl2_image/64/sdl2_image.dll $(prepath)/binaries/4windows/sdl2_image/64/libjpeg-9.dll $(prepath)/binaries/4windows/sdl2_image/64/libpng16-16.dll $(prepath)/binaries/4windows/sdl2_image/64/libtiff-5.dll $(prepath)/binaries/4windows/sdl2_image/64/libwebp-4.dll $(prepath)/binaries/4windows/sdl2_image/64/zlib1.dll #luaincludes = -i $(prepath)/lua/ #lualib = $(prepath)/lua/ -llua -lm  #where put compiled program compilepath = $(prepath)/binaries/    #build options  build: nlf.o     cp ./*.o $(compilepath)     $(cc) $(cflags) -shared -o $(compilepath)libnlf.dll $(sdl2libs) $(sdlimage2libs) $(compilepath)*.o  nlf.o: nlf_osservice.o nlf_error.o nlf_screen.o nlf.h.gch     $(cc) -c -dbuild_dll $(cflags) $(sdl2includes) $(sdlimage2includes) nlf.c nlf.h.gch: nlf.h     $(cc) $(cflags) $(sdl2includes) $(sdlimage2includes) nlf.h  nlf_osservice.o: nlf_osservice.h.gch     $(cc) -c -dbuild_dll $(cflags) $(sdl2includes) nlf_osservice.c nlf_osservice.h.gch:     $(cc) $(cflags) $(sdl2includes) nlf_osservice.h  nlf_error.o: nlf_error.h.gch     $(cc) -c -dbuild_dll $(cflags) $(sdl2includes) nlf_error.c nlf_error.h.gch:     $(cc) $(cflags) $(sdl2includes) nlf_error.h  nlf_screen.o: nlf_screen.h.gch     $(cc) -c -dbuild_dll $(cflags) $(sdl2includes) $(sdlimage2includes) nlf_screen.c nlf_screen.h.gch:     $(cc) $(cflags) $(sdl2includes) $(sdlimage2includes) nlf_screen.h    #cleaning options  clean-build:     rm -f -v $(compilepath)*.o  clean-all:     rm -f -v ./*.o ./*.h.gch     rm -f -v $(compilepath)*.o $(compilepath)*.so  clean-soft:     rm -f -v ./*.o ./*.h.gch     rm -f -v $(compilepath)*.o 

when running make all, compilation runs fine, when gets -shared part, this:

../binaries/4windows/sdl2/64/sdl2.dll: file not recognized:

i tried add -l before third party dll, this:

sdl2libs = -l $(prepath)/binaries/4windows/sdl2/64/sdl2.dll sdlimage2libs = -l $(prepath)/binaries/4windows/sdl2_image/64/sdl2_image.dll -l $(prepath)/binaries/4windows/sdl2_image/64/libjpeg-9.dll -l $(prepath)/binaries/4windows/sdl2_image/64/libpng16-16.dll -l $(prepath)/binaries/4windows/sdl2_image/64/libtiff-5.dll -l $(prepath)/binaries/4windows/sdl2_image/64/libwebp-4.dll -l $(prepath)/binaries/4windows/sdl2_image/64/zlib1.dll 

and undefined reference errors... same error if change line:

$(cc) $(cflags) -shared -o $(compilepath)libnlf.dll $(sdl2libs) $(sdlimage2libs) $(compilepath)*.o 

for

$(cc) $(cflags) $(sdl2libs) $(sdlimage2libs) -shared -o $(compilepath)libnlf.dll $(compilepath)*.o 

does know what's going on?

you should not use -l before library files. -l indicates library path. library files, should use -l (lowercase l). but, if you're indicating path file, , including file extension, don't need use -l, though. initial makefile correct in sense.

you should provide full error got, not just file not recognized:. bet file format not recognized error, indicates should not linking against .dll file, .lib files. similar problem here.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -