由买买提看人间百态

topics

全部话题 - 话题: lpthread
1 (共1页)
Y**G
发帖数: 1089
1
来自主题: Programming版 - gcc编译选项 -lpthread vs -pthread
-lpthread比较容易理解,就是连接libpthread库。后来试了一下,改成-pthread好像
也行,不知是为什么,请问有知道的可以解释一下吗?
w***g
发帖数: 5958
2
来自主题: Programming版 - gcc编译选项 -lpthread vs -pthread
-phtread是指让编译器在实现某些并行功能的时候产生使用pthread的代码,
隐含-lphtread. gcc似乎只有openmp依赖这个,并且-fopenmp隐含-pthread.
但是g++在编译某些C++并行功能的时候(比如std::async), 是否用
-pthread出来的效果是不一样的.我印象中如果不加-pthread,
std::launch::async是不起作用的,即使加了-lpthread也没用.
w*s
发帖数: 7227
3
来自主题: Linux版 - Makefile link lib question
This is what i want to run:
arm-none-linux-gnueabi-g++ -ldl -o db4 db4.o -L/somePath/sql3arm -lsqlite3
-lpthread
In makefile
LIBS = -L/somePath/sql3arm -lsqlite3 -lpthread
$(TARGET): $(OBJS)
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
when i run it, it's running with lib options
arm-none-linux-gnueabi-g++ -o db4 db4.o
Any suggestions pls, thanks very much !
r*****l
发帖数: 2859
4
来自主题: Programming版 - 问一个link的问题
我不是做c/c++的。但是工作需要build code。Make说找不到libstdc++.so.5。
哪位帮忙看一下,谢谢。
Makefile:
*******************************************
DIR=.
CXX=g++
CXXFLAGS=-g -O -Wall
LDLIBS=-L$(DIR) -Wl,-rpath,$(DIR)
all: oldsample newsample
oldsample: oldsample.cpp libaddr.h
$(CXX) $(CXXFLAGS) oldsample.cpp -o $@ $(LDLIBS) -laddr -lpthread
newsample: newsample.cpp mdAddr.h mdEnums.h
$(CXX) $(CXXFLAGS) newsample.cpp -o $@ $(LDLIBS) -lmdAddr -lpthread
clean:
$(RM) ???sample
******************
c*****a
发帖数: 808
5
来自主题: Programming版 - pedantic warning, 哪里错了
gcc -Wall -ansi -pedantic -c -o synch.o synch.c -lpthread -lrt
synch.c: In function ‘main’:
synch.c:48:2: warning: ISO C90 forbids mixed declarations and code [-
pedantic]
gcc -o synch synch.o -lpthread -lrt
第48行: pthread_t p, s;
..........盯了半天
d**********x
发帖数: 4083
6
来自主题: JobHunting版 - LinkedIn 面经
H2O那个我写了个C的。可以改吧改吧加上对各种原子的计数。
编译的时候别忘了 -lpthread !
#include
#include
#include
#include
#include
#include
sem_t availH;
sem_t availO;
sem_t usedH;
sem_t usedO;
void* H(void*) {
sem_post(&availH);
sem_wait(&usedH);
fprintf(stderr, "H consumed.\n");
pthread_detach(pthread_self());
return NULL;
}
void* O(void*) {
sem_post(&availO);
sem_wait(&usedO);
fprintf(stderr, "O consumed.\n");
pthread_detach(... 阅读全帖
d**********x
发帖数: 4083
7
来自主题: JobHunting版 - LinkedIn 面经
H2O那个我写了个C的。可以改吧改吧加上对各种原子的计数。
编译的时候别忘了 -lpthread !
#include
#include
#include
#include
#include
#include
sem_t availH;
sem_t availO;
sem_t usedH;
sem_t usedO;
void* H(void*) {
sem_post(&availH);
sem_wait(&usedH);
fprintf(stderr, "H consumed.\n");
pthread_detach(pthread_self());
return NULL;
}
void* O(void*) {
sem_post(&availO);
sem_wait(&usedO);
fprintf(stderr, "O consumed.\n");
pthread_detach(... 阅读全帖
R*******y
发帖数: 19
8
以下是我的makefile文件:
TARGETS=server client
TARGET_O=server.o client.o
CC=gcc
cFlags=-Wall -D __REENTRANT
lFlags=-Wall -lpthread -lnsl
.PHONY: all clean
all : $(TARGETS)
server : server.o
$(CC) $(lFlags) -o server server.o alg.o
client : client.o
$(CC) $(lFlags) -o client client.o alg.o
server.o : server.c swp.h crc.h function.h
$(CC) $(cFlags) -c server.c
congctrlserver : server.c swp.h crc.h function.h
$(CC) $(cFlags) -c server.c -DCONGCTRL
client.o : client.c c_crc.h c_common.h c_f
w*****3
发帖数: 910
9
来自主题: Linux版 - Fortran complier
准备compile CMAQ 一个大气模型软件。
里面的module 指明用PGI or Intel Fortran 。
Requirements: I/O API & netCDF libs, CVS, and PGI or Intel Fortran
但这两个fortran compiler 都不免费。
想用GNU gfortran 但是module中 Flags参数不一样。
#> Portland Group 9.01 Fortran Compiler Flags
#set FSTD = "-Mfixed -Mextend"
#set LINK_FLAGS = "-Bstatic"
#> Intel Fortran 10.1 Compiler Flags
set FSTD = "-extend_source 132 -vec-report0 -cm -w95 -c"
set LINK_FLAGS = "-liomp5 -lpthread -Bstatic"
不知道有哪位高手可以指点一下。
多谢了
S*A
发帖数: 7142
10
来自主题: Linux版 - Makefile link lib question
Your variable LIBS get overriden some where.
You can add debug line like
LIBS = -L/somePath/sql3arm -lsqlite3 -lpthread
$(info LIBS = $(LIBS))
$(TARGET): $(OBJS)
$(info LIBS = $(LIBS))
$(CXX) -o $(TARGET) $(OBJS) $(LIBS)
To see if the LIBS get changed before invoking CXX
c**t
发帖数: 2744
11
来自主题: Programming版 - Ask a g++ compilation qestion
g++ 3.2 就没有问题。3.4怎么不行?
$ make -f makefile all
rm -f ../../../../programs/libraries/libxmlparse.a
g++ -qmkshrobj -o ../../../../programs/libraries/libxmlparse.so ../../../../programs/libraries/static/libxmlparse_s.a
-blibpath:./programs/libraries:/usr/lib/threads:/lib:/usr/lib:/lib:/software/ace/ACE_wrappers/ace
-L/lib -ldl -lpthreads -ltli_r -lC_r
g++: `-b' must come at the start of the command line
make: *** [../../../../programs/libraries/libxmlparse.a] Error 1
$ g++ --version
g++
n**d
发帖数: 9764
12
来自主题: Programming版 - Semaphores in Linux (转载)
Yes, we can use gcc with -lrt or -lpthread to pass compile and link. What
does it mean? So can we say Linux supports both kinds of Semaphores?
g*********s
发帖数: 1782
13
linker只在LD_LIB_PATH和-L里找么?
-lc和-lpthread是怎么找的?我在这些目录里都找不到.但ldd给出是在/lib64/tls/下.
还有/usr/lib64等这些是标准的默认路径么?
b*******s
发帖数: 5216
14
#include "pthread.h"
gcc -lpthread
b*********n
发帖数: 2284
15
来自主题: Programming版 - 求救
请高人指点。今天第一次装MinGW编译cpp程序,多线程的计算程序,需要用OpenMP。我
用 gcc -fopenmp xxxx.cpp 编译,结果有如下错误
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot
find -lpthread
collect2.exe: error: ld returned 1 exit status
请教怎么解决,谢谢!
W***o
发帖数: 6519
16
来自主题: Programming版 - 求救
try:
gcc -fopenmp -lpthread xxx.cpp
openMP 的东西最好还是在LINUX环境下整方便点,而且有的LINUX还没有 openMP, MPI
library
上次用openMP, MPI 整多线程 的 synch/barrier lock发现 ubuntu 就没有这两个
library

cannot
f********s
发帖数: 526
17
来自主题: Programming版 - 有人在ubuntu 13.04上装过python 3.4吗?
我装了一下装不上, ./configure没问题, 但是接下来用make的时候, 系统提示这个错
误, 大牛给看看, 咋办啊? 多谢啦~
.....
copying and adjusting /home/yanwang/.local/share/Trash/files/Python-3.4.1/
Tools/scripts/2to3 -> build/scripts-3.4
copying and adjusting /home/yanwang/.local/share/Trash/files/Python-3.4.1/
Tools/scripts/pyvenv -> build/scripts-3.4
changing mode of build/scripts-3.4/pydoc3 from 664 to 775
changing mode of build/scripts-3.4/idle3 from 664 to 775
changing mode of build/scripts-3.4/2to3 from 664 to 775
changing mode of build... 阅读全帖
d****i
发帖数: 4809
18
来自主题: Programming版 - 请推荐C++开发环境
什么库呢?
No, you can't. Windows has its own threading library which is completely
different from pthread. If you really want to use pthread in Windows, you
need to use Cygwin as a layer of simulation. But after all, Cygwin is just a
dll in Windows environment, which is not true pthread anyway. But using
Cygwin gives you the convenience that same code can be run on both Windows
and Linux without modification. Do remember to use -lpthread flag in your
linker option.
Y**G
发帖数: 1089
19
来自主题: Programming版 - gcc编译选项 -lpthread vs -pthread
看来用

看来用-pthread兼容新性比较好
Y**G
发帖数: 1089
20
来自主题: Programming版 - gcc编译选项 -lpthread vs -pthread
多谢
h******a
发帖数: 198
21
来自主题: Unix版 - multithread programming
what compiler flag do u add? try gcc -pthread or -lpthread
what platform are u working?
1 (共1页)