-1

I have a Eclipse project using C programming language. I have been stuck with a problem related to linker error since two days now. I have checked various forums to find a solution. Tried a lot of the suggestions but could not resolve it. So as a last resort, i am asking question here. My main program MotorRun.c has code which calls functions in the static library FtMscLib_Static_LIBCMT_Release.Lib which is in Libs folder in the path C:\FT-Project\Common\Libs. I am using MinGW gcc compiler.

When i run the makefile, it generates an error:

c:/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.9.1/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lC:\FT-Project\Common\Libs\FtMscLib_Static_LIBCMT_Release.Lib
collect2.exe: error: ld returned 1 exit status

The code run by the makefile is

gcc "-LC:\\FT-Project\\Common\\Libs" -shared -o libRoboCopMinGW.exe "src\\MotorRun.o" "-lC:\\FT-Project\\Common\\Libs\\FtMscLib_Static_LIBCMT_Release.Lib"

By looking at the execution code, we can see that the paths and library name has been set correctly, but the linker just cannot find it so that it can link the library with my MotorRun.o object file. Hope someone can help me in finding a solution. The program MotorRun.c is a very simple one, so i am not posting it here. But if necessary i can update it later. Thanks in advance!

ams
  • 22,492
  • 4
  • 47
  • 71
Abinash
  • 21
  • 2
  • Ok, if you did [revert my edit](http://stackoverflow.com/revisions/30803765/2), that's fine, but at least make the question readable again. thanks. – Sourav Ghosh Jun 12 '15 at 13:06
  • You should probably run the gcc command with `-v` added. There might be a clue in there. – ams Jun 12 '15 at 13:11
  • @SouravGhosh. Sorry if it was not readable. I tried my best to write it clearly. I am a newbie here. – Abinash Jun 12 '15 at 13:12

1 Answers1

2

The correct linker syntax is typically something like:

-Lpath_to_library_directory -lname

where the library filename (for a Windows static library) would be name.lib. So your above linker line needs to lose the .lib part. You may also need to prefix the -l argument with another argument -static, to instruct the linker to search for the static library FtMscLib_Static_LIBCMT_Release.Lib otherwise it might try to find the DLL instead.

By the way, there are heaps of posts on StackOverflow regarding the issue of static and dynamic linking with MinGW, so feel free to search for these also. The MinGW web pages also have numerous tips on the same topic.