Author Topic: linking issues  (Read 3803 times)

hijinks

  • Guest
linking issues
« on: February 18, 2006, 06:17:14 pm »
I am having issues linking in a dll I created with codeblocks. I tried both creating it with a static .a file and a dynamic dll. I am using mingw as my compiler. I am trying to link in this library I called sensei.a/sensei.dll and having little luck.

My directory layout is like this

root
   src - all my .cpp/.h files in here
   sensei - my library code and .a/dll file

Now I have in my linking directory just "sensei"

and then in my linking files i just have "sensei.a" or "sensei.dll"

When I go to link the application it will not find those functions that are in the library. I have it compiled fine in linux. This is QT 4.1 application I am looking to compile in windows

any pointers?


below is the linking log

g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows -o "release\qsudoku.exe" object_script.qsudoku.Release  -L"C:\Qt\4.1.0\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4
mingw32-make.exe[2]: Leaving directory `C:/Documents and Settings/mike/Desktop/qsudoku'
./release\board.o(.text+0x93c):board.cpp: undefined reference to `ConstructBasicBoard'
mingw32-make.exe[1]: Leaving directory `C:/Documents and Settings/mike/Desktop/qsudoku'
./release\board.o(.text+0x9a6):board.cpp: undefined reference to `GetNumPossValuesOfCell'
./release\board.o(.text+0x9cc):board.cpp: undefined reference to `GetNumPossValuesOfCell'
./release\board.o(.text+0x9fc):board.cpp: undefined reference to `GetPossValuesOfCell'
./release\board.o(.text+0xa58):board.cpp: undefined reference to `SetSymbolInCell'
./release\board.o(.text+0xa6e):board.cpp: undefined reference to `Solve'
./release\board.o(.text+0xa7c):board.cpp: undefined reference to `GetState'
./release\board.o(.text+0xadf):board.cpp: undefined reference to `GetNumCells'
./release\board.o(.text+0xb0a):board.cpp: undefined reference to `GetBoardRaw'
./release\board.o(.text+0xd0e):board.cpp: undefined reference to `CleanBoard'
collect2: ld returned 1 exit status
mingw32-make.exe[2]: *** [release\qsudoku.exe] Error 1
mingw32-make.exe[1]: *** [release] Error 2
mingw32-make.exe: *** [release] Error 2
Process terminated with status 1 (0 minutes, 3 seconds)
10 errors, 0 warnings
« Last Edit: February 18, 2006, 06:24:28 pm by hijinks »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: linking issues
« Reply #1 on: February 18, 2006, 06:43:32 pm »
Hello,

Which version of C::B are you using?

Did you check if your include/lib pathes are correct? Did you check if you add the correct libraries to the linker?

Be careful. A dll could not be created static. A dll is a dynamic library, i.e., .dll or .so (in Linux).

A small suggestion. Do not use path with white space. It is never a good idea and could lead to errors difficult to spot.

Best wishes,
Michael

Offline TDragon

  • Lives here!
  • ****
  • Posts: 943
    • TDM-GCC
Re: linking issues
« Reply #2 on: February 18, 2006, 09:49:51 pm »
I am trying to link in this library I called sensei.a/sensei.dll and having little luck.
Quote
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows -o "release\qsudoku.exe" object_script.qsudoku.Release  -L"C:\Qt\4.1.0\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4
You don't have "sensei.a" anywhere in your command line, so how will GCC know to link with it? You'll need to add the fully qualified path to sensei.a in your project's Link Libraries list. (Or, if you were to follow standard GNU library naming procedure, name your output .a file "libsensei.a" and just add "sensei" to the Link Libraries list.)

I also note that your input file has a ".Release" extension, which I'm not at all certain GCC would recognize, so it also might help to change to a .o extension (see http://gcc.gnu.org/onlinedocs/gcc-3.4.5/gcc/Overall-Options.html#Overall-Options).
https://jmeubank.github.io/tdm-gcc/ - TDM-GCC compiler suite for Windows (GCC 9.2.0 2020-03-08, 32/64-bit, no extra DLLs)