big problem adding libraries to the project manager in C++20

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

big problem adding libraries to the project manager in C++20

Postby tomcat » Mon Jul 23, 2007 8:14 am

I dont know, if I where on the right place, but I have a problem with the C++Builder 2007:

In previous version, like C++Builder 4.0, I simply can add libraries to my projekt using the USELIB("mylibs.lib"); statement.

The importent matter was, that I can add libraries without full pathes.

In C++2007, I can add Libraries, but only with pathes. So, if I have my libs on - for example - c:\mylibs and other developers in different places, I can't share thies project.

Thats absolute horrible.

Is this a real problem or am I wrong?

Grüsse, Martin
tomcat
 

Postby gtokas » Tue Jul 24, 2007 7:33 am

You can use the other way that works also with BCB1...6.
From Project|Add To Project select "*.lib", browse to the directory the library is located and click on "Open" button...
Also you can modify the library path in "Project|Options |Directories/Conditionals" and add the path to the library, source, include....

George Tokas.
"Father is C++ Builder. I'm C++ Killer"
Vangelis Tokas.
12 years old.
gtokas
BCBJ Editor
BCBJ Editor
 
Posts: 78
Joined: Mon Feb 13, 2006 4:41 pm
Location: Thessaloniki Greece

Postby gtokas » Tue Jul 24, 2007 7:36 am

By the way...
The interface of Project|Options changed since BCB2006/BDS2006 but all those options including more are there also...
Just needs a bit of searching...

George Tokas.
"Father is C++ Builder. I'm C++ Killer"
Vangelis Tokas.
12 years old.
gtokas
BCBJ Editor
BCBJ Editor
 
Posts: 78
Joined: Mon Feb 13, 2006 4:41 pm
Location: Thessaloniki Greece

Postby tomcat » Wed Jul 25, 2007 7:38 am

gtokas wrote:You can use the other way that works also with BCB1...6.
From Project|Add To Project select "*.lib", browse to the directory the library is located and click on "Open" button...
Also you can modify the library path in "Project|Options |Directories/Conditionals" and add the path to the library, source, include....

George Tokas.


Hello George,

if I do so, I have the full path to the library in my project:
here a snipplet from the XML-cbproj:
...
< LibFiles Include="S:\m7rtm\lib\procedurelist.lib" >
...
So if my colleague check in (with cvs or so) this project, he has also the full path. But his libraries are possibly stored on other places. that is the problem.
Sure, I can (and in fact I do) edit the XML-Projectfile to strip of the path - but this isn't gracefully... and a horror an large projects...

the silly IDE should creates, and all thinks where fine :-)
...
< LibFiles Include="procedurelist.lib" >
...
tomcat
 

Postby gtokas » Wed Jul 25, 2007 7:54 am

I think that the second solution is better, add a path for the libraries...
This path sould be common to all, that means to have an exact location as a constant...
I used BCB4 and I don't recall any other option for that except those I described...

George Tokas.
"Father is C++ Builder. I'm C++ Killer"
Vangelis Tokas.
12 years old.
gtokas
BCBJ Editor
BCBJ Editor
 
Posts: 78
Joined: Mon Feb 13, 2006 4:41 pm
Location: Thessaloniki Greece

Postby minas » Wed Jul 25, 2007 10:38 am

Hi All,

in BCB 5 it works fine . Include the path in Project Options ->Directories -> Library Path and then use USELIB("myLib.lib") or USELIB("RelativeOrAbsolutePath\\myLib.lib") to link the library into the executable.

I have installed Turbo C++ Explorer 2006 and indeed USELIB is not working(Maybe I missed something) .
I use instead #pragma link "myLib.lib"(setting Library path in Project Options) or #pragma link "AbsolutePath\\myLib.lib" in project's source file like I used to with USELIB .

My project's source file
Code: Select all
#include <vcl.h>
#pragma hdrstop
#pragma link "testLIB2006.lib"
//---------------------------------------------------------------------------
USEFORM("Unit18.cpp", Form18);
/////// etc ////////



Just remember to include your library path in Linker Directories (Library Path) if you don't use the lib path inside the #pragma link directive.

I just see that in BCB 2006 #pragma link "RelativePath\\myLib.lib" is not working . Only with absolute path finds the lib.

Best Regards

_minas
-
User avatar
minas
BCBJ Guru
BCBJ Guru
 
Posts: 196
Joined: Sat Jul 10, 2004 6:09 am
Location: Greece

Postby tomcat » Thu Jul 26, 2007 12:49 am

[quote="min_char"]Hi All,

...

My project's source file
Code: Select all
#include <vcl>
#pragma hdrstop
#pragma link "testLIB2006.lib"
//---------------------------------------------------------------------------
USEFORM("Unit18.cpp", Form18);
/////// etc ////////


...

Hi _minas,

That's right. That's works - Thank you very much indeed.

Martin
tomcat
 

Re:

Postby amandak695 » Mon Sep 20, 2010 3:02 am

minas wrote:Hi All,

in BCB 5 it works fine . Include the path in Project Options ->Directories -> Library Path and then use USELIB("myLib.lib") or USELIB("RelativeOrAbsolutePath\\myLib.lib") to link the library into the executable.

I have installed Turbo C++ Explorer 2006 and indeed USELIB is not working(Maybe I missed something) .
I use instead #pragma link "myLib.lib"(setting Library path in Project Options) or #pragma link "AbsolutePath\\myLib.lib" in project's source file like I used to with USELIB .

My project's source file
Code: Select all
#include <vcl.h>
#pragma hdrstop
#pragma link "testLIB2006.lib"
//---------------------------------------------------------------------------
USEFORM("Unit18.cpp", Form18);
/////// etc ////////



Just remember to include your library path in Linker Directories (Library Path) if you don't use the lib path inside the #pragma link directive.

I just see that in BCB 2006 #pragma link "RelativePath\\myLib.lib" is not working . Only with absolute path finds the lib.

Best Regards

_minas

Well, great work! You have helped me to improve my knowledge about this field. Thank you so much for sharing.
amandak695
 
Posts: 1
Joined: Mon Sep 20, 2010 3:00 am

Re: big problem adding libraries to the project manager in C++20

Postby rlebeau » Tue Sep 21, 2010 11:35 am

tomcat wrote:In previous version, like C++Builder 4.0, I simply can add libraries to my projekt using the USELIB("mylibs.lib"); statement.


The USE...() macros were deprecated in BCB 6. External file references are stored in the .bpr file now. Use the Project Manager's "Add to Project" option to add files to the project.

tomcat wrote:The importent matter was, that I can add libraries without full pathes.


File path references in the .bpr can be relative or absolute paths.

Alternatively, you can use a
Code: Select all
#pragma comment(lib, ...)
statement in the code. But then the Project Manager cannot manage the file for you.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1605
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA


Return to Technical

Who is online

Users browsing this forum: No registered users and 11 guests