* static or shared
@ 2003-01-07 11:19 Mohammed Khalid Ansari
2003-01-07 13:17 ` Jan-Benedict Glaw
2003-01-07 17:10 ` Glynn Clements
0 siblings, 2 replies; 6+ messages in thread
From: Mohammed Khalid Ansari @ 2003-01-07 11:19 UTC (permalink / raw)
To: linux c programming mailing list
Hi,
If /usr/lib contains both static and shared libraries of the same name
eg odbc, which library compiler is going to take if I do..
gcc file.c -lodbc
How do I explicitly I define which library to take during compilation.
--
**************************************************************************
Mohammed Khalid Ansari Tel (res) : 0091-022-3051360
Assistant Manager II (off) : 0091-022-2024641
National Centre for Software Technology Fax : 0091-022-2049573
8th flr,Air India Build. Nariman Point, E-Mail : khalid@ncst.ernet.in
Mumbai 400021.
Homepage : http://soochak.ncst.ernet.in/~khalid
**************************************************************************
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: static or shared
2003-01-07 11:19 static or shared Mohammed Khalid Ansari
@ 2003-01-07 13:17 ` Jan-Benedict Glaw
2003-01-07 17:10 ` Glynn Clements
1 sibling, 0 replies; 6+ messages in thread
From: Jan-Benedict Glaw @ 2003-01-07 13:17 UTC (permalink / raw)
To: linux c programming mailing list
[-- Attachment #1: Type: text/plain, Size: 956 bytes --]
On Tue, 2003-01-07 16:49:29 +0530, Mohammed Khalid Ansari <khalid@ncst.ernet.in>
wrote in message <Pine.LNX.4.33.0301071646230.5493-100000@soochak.ncst.ernet.in>:
>
> Hi,
>
> If /usr/lib contains both static and shared libraries of the same name
> eg odbc, which library compiler is going to take if I do..
>
> gcc file.c -lodbc
>
> How do I explicitly I define which library to take during compilation.
"-l" is commonly used for shared libraries. If you want to statically
link some library into your program, simply name it's file name as one
of the object file names which are to be linked. But beware! Libs need
to be on the end of your file list.
MfG, JBG
--
Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481
"Eine Freie Meinung in einem Freien Kopf | Gegen Zensur
fuer einen Freien Staat voll Freier Bürger" | im Internet!
Shell Script APT-Proxy: http://lug-owl.de/~jbglaw/software/ap2/
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: static or shared
2003-01-07 11:19 static or shared Mohammed Khalid Ansari
2003-01-07 13:17 ` Jan-Benedict Glaw
@ 2003-01-07 17:10 ` Glynn Clements
2003-01-07 23:43 ` strange segmentation fault in malloc() qhwang
1 sibling, 1 reply; 6+ messages in thread
From: Glynn Clements @ 2003-01-07 17:10 UTC (permalink / raw)
To: Mohammed Khalid Ansari; +Cc: linux c programming mailing list
Mohammed Khalid Ansari wrote:
> If /usr/lib contains both static and shared libraries of the same name
> eg odbc, which library compiler is going to take if I do..
>
> gcc file.c -lodbc
Shared libraries are preferred over static libraries, unless you use
the -static flag (in which case, only static libraries are used).
> How do I explicitly I define which library to take during compilation.
You can specify an explicit filename, e.g. /usr/lib/libodbc.a
(however, you shouldn't do this for shared libraries).
IIRC, you can also use e.g.
gcc ... -Wl,-Bstatic -lodbc -Wl,-Bdynamic ...
to link specific libraries statically.
--
Glynn Clements <glynn.clements@virgin.net>
^ permalink raw reply [flat|nested] 6+ messages in thread
* strange segmentation fault in malloc()
2003-01-07 17:10 ` Glynn Clements
@ 2003-01-07 23:43 ` qhwang
2003-01-08 0:38 ` Glynn Clements
0 siblings, 1 reply; 6+ messages in thread
From: qhwang @ 2003-01-07 23:43 UTC (permalink / raw)
To: linux-c-programming
Hi, there!
My app wants to read and then wavelet-transform image one by one. Now I got
a strange segmentation fault in malloc(). The situation is only the first
image can be processed successfully, but the second one fails due to the
same call of "malloc(160*120*sizeof(float))" used in the processing of the
first image. The return value of "malloc" is NULL . So how can I check the
size of heap used by the system? Or how can I set the environment varible
"MALLOC_CHECK_"? Someone said it can be set in the rc.sysinit, but I can't
find this file. Any suggestion will be greatly appreciated. Many Thanks!
qhwang
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: strange segmentation fault in malloc()
2003-01-07 23:43 ` strange segmentation fault in malloc() qhwang
@ 2003-01-08 0:38 ` Glynn Clements
2003-01-08 13:40 ` QingHua Wang
0 siblings, 1 reply; 6+ messages in thread
From: Glynn Clements @ 2003-01-08 0:38 UTC (permalink / raw)
To: qhwang; +Cc: linux-c-programming
qhwang wrote:
> My app wants to read and then wavelet-transform image one by one. Now I got
> a strange segmentation fault in malloc(). The situation is only the first
> image can be processed successfully, but the second one fails due to the
> same call of "malloc(160*120*sizeof(float))" used in the processing of the
> first image. The return value of "malloc" is NULL . So how can I check the
> size of heap used by the system?
In bash, "ulimit -a" will report the resource limits. However, the
malloc() function in GNU libc isn't restricted to the size of the data
segment, as it can obtain memory using "anonymous mmap()".
In any case, it's unlikely that you are really running out of memory
(160*120*sizeof(float) is only 75Kb). Unusual malloc() failures (i.e.
failures which occur when you aren't using vast amounts of memory) are
usually caused by the heap's data structures being corrupted because
part of the code modified memory outside of the allocated block.
> Or how can I set the environment varible
> "MALLOC_CHECK_"? Someone said it can be set in the rc.sysinit, but I can't
> find this file. Any suggestion will be greatly appreciated. Many Thanks!
You can set environment variables in bash using "export", e.g.
export MALLOC_CHECK_=1
Setting an environment variable affects all process which inherit from
the shell in which it was set.
--
Glynn Clements <glynn.clements@virgin.net>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: strange segmentation fault in malloc()
2003-01-08 0:38 ` Glynn Clements
@ 2003-01-08 13:40 ` QingHua Wang
0 siblings, 0 replies; 6+ messages in thread
From: QingHua Wang @ 2003-01-08 13:40 UTC (permalink / raw)
To: Glynn Clements; +Cc: linux-c-programming
Thanks. I found the problem by set MALLOC_CHECK_. It's a kind of pointer
corruption in the couple of malloc/free. Thanks again.
qhwang
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-01-08 13:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-07 11:19 static or shared Mohammed Khalid Ansari
2003-01-07 13:17 ` Jan-Benedict Glaw
2003-01-07 17:10 ` Glynn Clements
2003-01-07 23:43 ` strange segmentation fault in malloc() qhwang
2003-01-08 0:38 ` Glynn Clements
2003-01-08 13:40 ` QingHua Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).