[c] is -lpthread correct option?


 
Thread Tools Search this Thread
Top Forums Programming [c] is -lpthread correct option?
# 1  
Old 08-03-2010
[c] is -lpthread correct option?

I read somewhere that I should use -pthread instead of -lpthread as compiler/linker flag, or define _REENTRANT. Is this incorrect to use only -lpthread? (I use gcc)
# 2  
Old 08-03-2010
With what OS and architecture ?
# 3  
Old 08-03-2010
Linux x86, x86_64 and FreeBSD x86, x86_64
# 4  
Old 08-03-2010
Older compilers often have/had requirements for other option flags but any modern compiler (say post 1999) should only require -lpthread.
# 5  
Old 08-03-2010
So I don't have to use -pthread or -D_REENTRANT?
I use -lpthread only when linking. For example:
gcc test.c -c -o test.o
gcc test.o -lpthread
Isn't that incorrect? (I know -l is linker option, but I want to be absolutely sure)
# 6  
Old 08-03-2010
It doesn't hurt to define _REENTRANT, even if it doesn't need to be required with current header files.
I would still use -pthread instead of -lpthread.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Correct use of substr

I have a file that looks like this: >ID_1 ATGCATGC >ID_2 ATGCATGC >ID_3 ATGCATGC >ID_4 ATGCATGC And I am using the following script to "extract" specific positions from the sequences: awk '/^>/{id=$0; next}{ print id "\n" substr( $1,1,1 ) substr ($1,4,2 ) substr ($1,7,1) }'... (12 Replies)
Discussion started by: Xterra
12 Replies

2. Solaris

Unrecognized option: sparc-sun-Solaris2.10/bin/as: unrecognized option `-m32'

Hi, I installed some packages required by an app built with python. But when I try python setup.py install, I get the following error: /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.2.0/../../../../sparc-sun-solaris2.10/bin/as: unrecognized option `-m32' Could anyone tell me what's wrong... (4 Replies)
Discussion started by: Kimkun
4 Replies

3. Shell Programming and Scripting

recently introduced to the newer option for find...does an older option exist?

To find all the files in your home directory that have been edited in some way since the last tar file, use this command: find . -newer backup.tar.gz Is anyone familiar with an older solution? looking to identify files older then 15mins across several directories. thanks, manny (2 Replies)
Discussion started by: mr_manny
2 Replies

4. Solaris

in correct drive name

I am new to solaris and I replaced a faulty tape drive sun DLT7000 But, I am getting the follwoing error when system reboots ltid deamon error drive index 1 is not correct, drive name /dev/rmt/2cbn is incorrect no such file or directory. I have two drives the other one is /dev/rmt/0cbn,... (8 Replies)
Discussion started by: latif1958
8 Replies

5. Solaris

correct usage of find's -prune option

I know one of the more seasoned veterans probably opened this thread looking for their chance to refer me to the site's search feature and let me tell you. I'VE LOOKED!!!! And I didn't find anything helpful... So, I've got a windows background and I'm fond of its search feature which comes... (6 Replies)
Discussion started by: ProGrammar
6 Replies

6. Shell Programming and Scripting

Please correct this

I have input file like this Input file: ABC|abc_etc_passwd XYZ|XYZ_etc_passwd zXY|XYZ_etc_passwd IJK|test_etc_passwd KLM|test_etc_passwd i want to do following in a loop. grep 'ABC' *abc_etc_passwd* grep 'XYZ' *XYZ_etc_passwd* grep 'ZXY' *ZXY_etc_passwd* i have tried this for i... (2 Replies)
Discussion started by: pinnacle
2 Replies

7. Shell Programming and Scripting

can u please confirme the correct

st1=hello st2=world if && || ] ] ..... .... fi (5 Replies)
Discussion started by: mail2sant
5 Replies

8. Shell Programming and Scripting

Please correct the code

Hi, Some part of output: ================ $ hwmgr show scsi SCSI DEVICE DEVICE DRIVER NUM DEVICE FIRST HWID: DEVICEID HOSTNAME TYPE SUBTYPE OWNER PATH FILE VALID PATH ------------------------------------------------------------------------- 68: ... (10 Replies)
Discussion started by: mansa
10 Replies

9. Shell Programming and Scripting

option followed by : taking next option if argument missing with getopts

Hi all, I am parsing command line options using getopts. The problem is that mandatory argument options following ":" is taking next option as argument if it is not followed by any argument. Below is the script: while getopts :hd:t:s:l:p:f: opt do case "$opt" in -h|-\?)... (2 Replies)
Discussion started by: gurukottur
2 Replies

10. Programming

probs compiling with gcc + lpthread

Im trying to write a program atm which uses mutexes to control thread access to a certain code section ( the critical section). However, whenever I compile the code using gcc I get the following message from gcc Unresolved text symbol "pthread_mutex_lock" Unresolved text symbol... (1 Reply)
Discussion started by: JamesGoh
1 Replies
Login or Register to Ask a Question