help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with G++ on Solaris


From: Paul Pluzhnikov
Subject: Re: Help with G++ on Solaris
Date: Sun, 17 Dec 2006 06:31:52 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

ckkwan@my-deja.com writes:

> Using sem_open, sem_close, sem_post and sem_wait in my c++ file.
> compiled using command below:

This command line is almost completely bogus:

> g++ -g -I/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/include -L
> /usr/lib/ -B /usr/lib/sparcv9/libpthread.so hello.cpp -o hello

1. The '-I/opt/sfw/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/include'
   is unnecessary because 'gcc' (assuming it is 2.95.3) will add it
   automatically.

1a. The '-L /usr/lib' is also unneccessary, since linker will look
    there by default.

2. The '-B' means somethig else to 'gcc' as well.

3. System libraries should follow your sources/objects/libraries
   on the link line.

4. You are trying to link 32-bit hello.o against 64-bit libpthread.so

Try this:

  g++ -g -pthreads hello.cpp -o hello -lrt

> May I know what is wrong?

Just about everything on your 

> and how can I find out which library are all
> these semaphore functions in?

$ /usr/ccs/bin/nm -pA /usr/lib/lib*.so | grep sem_open
/usr/lib/libposix4.so: 0000018648 T _sem_open
/usr/lib/libposix4.so: 0000018648 T sem_open
/usr/lib/librt.so: 0000018648 T _sem_open
/usr/lib/librt.so: 0000018648 T sem_open

> The man page doesn't help much :(

Yes, it does:

SYNOPSIS
     cc [ flag... ] file... -lrt [ library... ]
                            ^^^^
Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]