简体   繁体   中英

How to solve undefined reference to _imp__** while building a console application in DEV-CPP linked to a static library?

Background Information
I'm trying to build the GAUL library according to this Instructions .

The Problem
Well I have two static libraries in C, build by me in Dev-CPP Windows 7 64 bit, one referencing the other.

And to test those I created a Console Application which referenced them.

Well when I tried to compile this is the log I getting:

> Compiler: Default compiler  
> Building Makefile: "C:\Soft\GAUL\Makefile.win"  
> Executing  make...  
> make.exe -f  
> "C:\Soft\GAUL\Makefile.win" all  
> **gcc.exe ../gaul-devel-windows/examples/struggle.o  -o "struggle.exe" -L"C:/Dev-Cpp/lib" gaul-util.a gaul-devel.a**    
>   
> gaul-util.a(memory_util.o)(.text+0x2e):memory_util.c: undefined reference to '_imp__mem_chunk_new_real'  
> gaul-util.a(memory_util.o)(.text+0x6c):memory_util.c: undefined reference to '_imp__mem_chunk_free_real'  
> ...  
> gaul-devel.a(ga_core.o)(.text+0x101):ga_core.c: undefined reference to 'slink_free_all'   
> gaul-devel.a(ga_core.o)(.text+0x360):ga_core.c: undefined reference to 'mem_chunk_new_real'  
> ...  
> collect2: ld returned 1  
> exit status
> 
> make.exe: *** [struggle.exe] Error 1
> 
> Execution terminated

I think that it has something to do with the parameters being used in the gcc command.

Actual Status
I've tried:
- Copying the libraries to C:\\Dev-Cpp\\lib
- Using the whole address before the libraries names
- Using -l before the libaries names
- Not using .a after the names

Not successful results with any of those.

Could anyone point me in the right direction?

Thanks in advance.

The order of the arguments for linker (ld) is important. If your build fails on the

gcc.exe ../gaul-devel-windows/examples/struggle.o  -o "struggle.exe" -L"C:/Dev-Cpp/lib" gaul-util.a gaul-devel.a

line, then try reversing the order of the last two files:

gcc.exe ../gaul-devel-windows/examples/struggle.o  -o "struggle.exe" -L"C:/Dev-Cpp/lib" gaul-devel.a gaul-util.a

最后,@ ThiefMaster♦说,在这种情况下,我使用了一个较新的生成器VC ++,它确实起作用了!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM