News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

trying to include a static lib in my project

Started by maxv, March 27, 2008, 11:57:14 AM

Previous topic - Next topic

maxv

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:


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

MortenMacFly

Quote from: maxv on March 27, 2008, 11:57:14 AM
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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

maxv

So, I added the Directory under Build Options -> Search Directories -> Linker,
hope that was what you meant.

There's a different error now:


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

MortenMacFly

Quote from: maxv on March 27, 2008, 05:56:32 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

maxv


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

MortenMacFly

Quote from: maxv on March 27, 2008, 10:14:30 PM

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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

maxv


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

MortenMacFly

Quote from: maxv on March 28, 2008, 10:49:24 AM

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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

maxv

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:


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

dje

Hi !

Quote from: maxv on March 28, 2008, 11:49:11 AM
   -lsqlite.lib -lsqlite.lib
I think once is enough  :)

Quote from: maxv on March 28, 2008, 11:49:11 AM
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

maxv

Quote from: dje on March 28, 2008, 12:49:56 PM
Hi !

Quote from: maxv on March 28, 2008, 11:49:11 AM
   -lsqlite.lib -lsqlite.lib
I think once is enough  :)

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

Quote from: dje on March 28, 2008, 12:49:56 PM
Quote from: maxv on March 28, 2008, 11:49:11 AM
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

dje

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

maxv

#12
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.

dje

Quote from: maxv on March 28, 2008, 05:13:24 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...

maxv

#14
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:


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