473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

question about linux static libraries

Hello guys, sorry for the really dumb question, but I'm just beginner in
linux programming. I have the following code in test.c:

#include <stdio.h>
#include <libpq-fe.h>

int main() {
int do_init = 1;
PQinitSSL(do_init);
}

.... so I just want to call one function from postgres library. According
to the nm command (nm /usr/lib/libpq.a) the object (which contains
PQinitSSL() function contains also number of SSL functions e.g. BIO_free,
BIO_new_mem_buf etc. When I'm trying to compile test program with command:

gcc -o test test.c -lpq

everything is OK, but when I'm trying to compile the same code with the
libpq library in the local directory, I've got a lot of undefined
reference messages on SSL functions

cp /usr/lib/libpq.a .
gcc -o test test.c -L. -lpq

So, how it is possible, that the first command works fine and the
second not ? I'm trying to compile it with the same library in both
cases. I know, that libpq.a library does not contains libcrypto.a
library. Are in the libpq.a (and generally any other) library references
to the other libraries ? And how can I determine those references ? Is it
possible with nm command ? Many thanks for the help.

Mar 15 '06 #1
2 1989

Brano wrote:
Hello guys, sorry for the really dumb question, but I'm just beginner in
linux programming. I have the following code in test.c:


And what prompted you to ask here? Your question has nothing to do with
C, and everything to do with your tools and possibly OS. You stand a
chance of getting an answer in groups dedicated to Linux and/or GCC.
Here, only Standard C is discussed. Have a look at
<http://www.clc-wiki.net/wiki/Introduction_to_comp.lang.c> before
posting again.

--
BR, Vladimir

Mar 15 '06 #2
Brano wrote:
... so I just want to call one function from postgres library. According
to the nm command (nm /usr/lib/libpq.a) the object (which contains
PQinitSSL() function contains also number of SSL functions e.g. BIO_free,
BIO_new_mem_buf etc. When I'm trying to compile test program with command:
libpq.a contains references to those functions, not the functions.
gcc -o test test.c -lpq
This probably links agains the .so, not the static lib (hint : ldd binary)
everything is OK, but when I'm trying to compile the same code with the
libpq library in the local directory, I've got a lot of undefined
reference messages on SSL functions

cp /usr/lib/libpq.a .
gcc -o test test.c -L. -lpq

So, how it is possible, that the first command works fine and the
second not ?
Because the first one uses the .so (which also contains the
dependencies), while the second one uses the .a, which only contains
references to the SSL functions, not where to get them.

I'm trying to compile it with the same library in both cases. I know, that libpq.a library does not contains libcrypto.a
library. Are in the libpq.a (and generally any other) library references
to the other libraries ? And how can I determine those references ? Is it
possible with nm command ? Many thanks for the help.


See the nm manual for that. The U symbol type is most interesting in
this case.
Igmar
Mar 20 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: Michael Foord | last post by:
I'd like to formalise slightly the license I release my projects under. At the moment it's 'free to use, modify, distribute and relicense'. This is basically fine as I don't want t oprevent people...
0
by: Samuel M. Smith | last post by:
I can build python 2.4.2 from source on the embedded linux box when I nfs mount and boot a full debian distribution. The embedded box also has stripped down linux distribution in onboard flash....
15
by: Notre Poubelle | last post by:
Hello, I have a large legacy MFC application. As is typical, there is an executable along with several MFC DLLs. One of these DLLs is created by staticly linking in many libraries resulting in...
2
by: mrstephengross | last post by:
I'm working with the freeze utility, and I'm trying to learn the basics. For the most part, I think I understand how it works. I have a question about modules, though. I want to make sure that...
14
by: Sumit77Sen | last post by:
who calls main() ?
1
by: krivenok.dmitry | last post by:
Hello All! I have developed my application and I want to install it on server of my client. Development platform is Gentoo Linux. Target platform is Debian Linux. This is the output of "ldd"...
5
by: t f | last post by:
Hi Okay this should be a simple one... In my solution i have 2 projects (one class library and one control library) - they both share the name default namespace - question is I want to be...
1
by: viraj.kadakia | last post by:
I observe a behavior with shared libraries (.so) and global variables that I cannot understand ... I'd appreciate if someone can explain the behavior .. Scenario 1: aTest is an executable on...
1
by: tvnaidu | last post by:
I have windows code to port to Linux, there are some static libraries like xyz.lib, also shared libs ABC.dll, I have to convert those static and shared libs (basically static will be used to make...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.