Author Topic: trying to include a static lib in my project  (Read 9750 times)

Offline maxv

  • Single posting newcomer
  • *
  • Posts: 8
trying to include a static lib in my project
« on: March 27, 2008, 11:57:14 am »
Hi all,

I'm new to this IDE and I've got a little problem
including a static library in my project.
Exactly: I'm trying to include a static sqlite lib.

I putted the lib in the Linker Options and included the
header File.

I may compile the whole Project without an error,
but when the Linker trys to link the files:

Code
C:\Programme\CodeBlocks\MinGW\bin\ld.exe: cannot find -lsqlite.lib
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

The file sqlite.lib is in the Project Directory.
So, what can I do about this?
Thanks in advance,

Max

PS: sry for my bad english :S

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: trying to include a static lib in my project
« Reply #1 on: March 27, 2008, 04:40:10 pm »
The file sqlite.lib is in the Project Directory.
So, what can I do about this?
Add the project path to the linker directories within the build options.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline maxv

  • Single posting newcomer
  • *
  • Posts: 8
Re: trying to include a static lib in my project
« Reply #2 on: March 27, 2008, 05:56:32 pm »
So, I added the Directory under Build Options -> Search Directories -> Linker,
hope that was what you meant.

There's a different error now:

Code
mingw32-g++.exe: no input files
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: trying to include a static lib in my project
« Reply #3 on: March 27, 2008, 09:00:29 pm »
There's a different error now:
Enable full logging (see my sig) and then report back the whole build log.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline maxv

  • Single posting newcomer
  • *
  • Posts: 8
Re: trying to include a static lib in my project
« Reply #4 on: March 27, 2008, 10:14:30 pm »
Code
mingw32-g++.exe -L"C:\Dokumente und Einstellungen\Max\Desktop\DatenbankAnbindung\"  -o bin\Debug\DatenbankAnbindung.exe obj\Debug\main.o obj\Debug\Datenbank.o    -lsqlite.lib -lsqlite.lib 
mingw32-g++.exe: no input files

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: trying to include a static lib in my project
« Reply #5 on: March 28, 2008, 08:22:35 am »
Code
mingw32-g++.exe -L"C:\Dokumente und Einstellungen\Max\Desktop\DatenbankAnbindung\"  -o bin\Debug\DatenbankAnbindung.exe obj\Debug\main.o obj\Debug\Datenbank.o    -lsqlite.lib -lsqlite.lib 
mingw32-g++.exe: no input files
Do a re-build and report back the whole log, please. BTW: So far I see already that you are linking against sqlite twice. That's for sure a (first) error.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline maxv

  • Single posting newcomer
  • *
  • Posts: 8
Re: trying to include a static lib in my project
« Reply #6 on: March 28, 2008, 10:49:24 am »
Code
Compiling: main.cpp
Compiling: Datenbank.cpp
Linking console executable: bin\Debug\DatenbankAnbindung.exe
mingw32-g++.exe: no input files
Process terminated with status 1 (0 minutes, 5 seconds)
0 errors, 0 warnings

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: trying to include a static lib in my project
« Reply #7 on: March 28, 2008, 11:28:29 am »
Code
Compiling: main.cpp
Compiling: Datenbank.cpp
Linking console executable: bin\Debug\DatenbankAnbindung.exe
mingw32-g++.exe: no input files
Process terminated with status 1 (0 minutes, 5 seconds)
0 errors, 0 warnings
Oh come one... you did not use the full compiler log again. Enable full compiler log, then rebuild and post the whole log. That shouldn't be too difficult.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline maxv

  • Single posting newcomer
  • *
  • Posts: 8
Re: trying to include a static lib in my project
« Reply #8 on: March 28, 2008, 11:49:11 am »
Sorry, my last post was ....

I'm currently not at home so, I'm working with my
notebook and other compiler settings :S

Here are the new and right ones:

Code
mingw32-g++.exe -Wall -fexceptions  -g     -c "C:\max\programme\der Rest\DatenbankAnbindung\main.cpp" -o obj\Debug\main.o
mingw32-g++.exe -Wall -fexceptions  -g     -c "C:\max\programme\der Rest\DatenbankAnbindung\Datenbank.cpp" -o obj\Debug\Datenbank.o
mingw32-g++.exe -L..\DatenbankAnbindung  -o bin\Debug\DatenbankAnbindung.exe obj\Debug\main.o obj\Debug\Datenbank.o    -lsqlite.lib -lsqlite.lib
C:\Programme\CodeBlocks\MinGW\bin\ld.exe: cannot find -lsqlite.lib
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 11 seconds)
1 errors, 0 warnings

~Max

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: trying to include a static lib in my project
« Reply #9 on: March 28, 2008, 12:49:56 pm »
Hi !

   -lsqlite.lib -lsqlite.lib
I think once is enough  :)

C:\Programme\CodeBlocks\MinGW\bin\ld.exe: cannot find -lsqlite.lib
Add the directory where sqlite.lib is located in the linker search directories of your project build options.

Dje

Offline maxv

  • Single posting newcomer
  • *
  • Posts: 8
Re: trying to include a static lib in my project
« Reply #10 on: March 28, 2008, 01:21:24 pm »
Hi !

   -lsqlite.lib -lsqlite.lib
I think once is enough  :)

umm... I've added the lib only once in the Build Options

C:\Programme\CodeBlocks\MinGW\bin\ld.exe: cannot find -lsqlite.lib
Add the directory where sqlite.lib is located in the linker search directories of your project build options.

Dje

Already done but thanks for trying to help anyway

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: trying to include a static lib in my project
« Reply #11 on: March 28, 2008, 02:44:47 pm »
I never worked with sqlite; is sqlite.lib in ..\DatenbankAnbindung ?
I would have imagine some <...>\sqlite\lib directory...
Are you sure of your relative path ? Did you try with an absolute one (not a good practice but just to be sure it is OK) ?

Dje

Offline maxv

  • Single posting newcomer
  • *
  • Posts: 8
Re: trying to include a static lib in my project
« Reply #12 on: March 28, 2008, 05:13:24 pm »
Quote
I never worked with sqlite; is sqlite.lib in ..\DatenbankAnbindung ?
I would have imagine some <...>\sqlite\lib directory...
No, it's only one library you have to build yourself...
or download the *.dll
I builded the static library myself and it works fine with Borland C++ Builder 2007.

Quote
Are you sure of your relative path ? Did you try with an absolute one (not a good practice but just to be sure it is OK) ?
I putted the lib in the linker options and putted the project path under Search Directories -> Linker.
So, yes I'm sure about the relative path.
« Last Edit: March 28, 2008, 05:14:55 pm by maxv »

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: trying to include a static lib in my project
« Reply #13 on: March 28, 2008, 05:20:14 pm »
I builded the static library myself and it works fine with Borland C++ Builder 2007.
I'm not sure it's a good idea to use a lib built with borland and link with mingw...

Offline maxv

  • Single posting newcomer
  • *
  • Posts: 8
Re: trying to include a static lib in my project
« Reply #14 on: March 28, 2008, 06:06:37 pm »
I also did a rebuild, same error but,
I'll do a right now... mom (5mins  :P)

Ok, needed a bit longer,
made the whole project new.

So, I rebuilded the lib as a static lib which
resulted in a *.a and a *.dll file,
when I builded a static lib with Borland I only got
a *.lib file.

Anyways, I added the *.a file under Building Options -> Linker Settings
and added the relative Project Directorie under Search Directories -> Linker.

Finally I got another error:

Code
mingw32-g++.exe -L..\DatenbankAnbindung  -o bin\Debug\DatenbankAnbindung.exe obj\Debug\main.o    ..\libsqlitestat.a 
obj\Debug\main.o: In function `main':
C:/max/programme/der Rest/DatenbankAnbindung/DatenbankAnbindung/main.cpp:9: undefined reference to `Datenbank::open(std::string)'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 13 seconds)
1 errors, 0 warnings

In my opinion the last project file was corrupted and
the linker tried to link the sqlite.lib file two times which lead to the error.

For this new project I don't even have a idea about the problem.

Maybe this is an easy problem and I just don't know enough about
libraries etc ... :/

~max
« Last Edit: March 28, 2008, 07:10:58 pm by maxv »