I compiled successfully BOTAN-2 (botan.exe BOTAN-test.exe runnable).
When I build QSsh's Project under Qt Creator I've got a linking error on std::thead (Compiler MinGW32)
rsa.cpp:-1: erreur : undefined reference to std::thread::_State::~_State()
rsa.cpp:-1: erreur : undefined reference to std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())
A added unsuccessfully in the file qssh/src/libs/ssh.pro :
LIBS += -lbotan-2
LIBS += -lpthread
QMAKE_CXXFLAGS += -std=c++11 -pthread
QMAKE_CFLAGS += -std=c++11 -pthread
Note : I made a simple program ("hello world" style) using pthread with success.
g++ main.cpp -o build32/prog.exe -std=c++11 -pthread (MSYS2/MinGW32)
What's wrong with QSsh ?
Thanks
Related
It runs good at a windows platform. But when I switch platform to webgl and build it, there is an error as following. As a beginner of Unity, it hard for me to figure out what happened, so I try to search for some answers. But there seems few similar questions.
Building Library\Bee\artifacts\WebGL\il2cpp\master_WebGL_wasm\9tk2_eric0.lump.o failed with output:
In file included from Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/ipux_Generic0.lump.cpp:3:
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Generic\WaitObject.cpp:94:36: error: 'SetWaitObject' is a private member of 'il2cpp::os::ThreadImpl'
currentThread->SetWaitObject(this);
^
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Posix\ThreadImpl.h:105:14: note: declared private here
void SetWaitObject(posix::PosixWaitObject* waitObject);
^
In file included from Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/ipux_Generic0.lump.cpp:3:
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Generic\WaitObject.cpp:94:50: error: cannot initialize a parameter of type 'posix::PosixWaitObject *' with an rvalue of type 'il2cpp::os::WaitObject *'
currentThread->SetWaitObject(this);
^~~~
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Posix\ThreadImpl.h:105:52: note: passing argument to parameter 'waitObject' here
void SetWaitObject(posix::PosixWaitObject* waitObject);
^
In file included from Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/ipux_Generic0.lump.cpp:3:
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Generic\WaitObject.cpp:148:36: error: 'SetWaitObject' is a private member of 'il2cpp::os::ThreadImpl'
currentThread->SetWaitObject(NULL);
^
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Posix\ThreadImpl.h:105:14: note: declared private here
void SetWaitObject(posix::PosixWaitObject* waitObject);
^
In file included from Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/ipux_Generic0.lump.cpp:3:
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Generic\WaitObject.cpp:161:36: error: 'SetWaitObject' is a private member of 'il2cpp::os::ThreadImpl'
currentThread->SetWaitObject(NULL);
^
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Posix\ThreadImpl.h:105:14: note: declared private here
void SetWaitObject(posix::PosixWaitObject* waitObject);
^
In file included from Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/ipux_Generic0.lump.cpp:3:
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Generic\WaitObject.cpp:227:17: error: no member named 'AcquireSemaphore' in 'il2cpp::os::ThreadImpl'
thread->AcquireSemaphore();
~~~~~~ ^
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Generic\WaitObject.cpp:238:28: error: no member named 'TryTimedAcquireSemaphore' in 'il2cpp::os::ThreadImpl'
bool ret = thread->TryTimedAcquireSemaphore(timeout);
~~~~~~ ^
D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\il2cpp\libil2cpp\os\Generic\WaitObject.cpp:264:33: error: no member named 'ReleaseSemaphore' in 'il2cpp::os::ThreadImpl'
object->thread->ReleaseSemaphore();
~~~~~~~~~~~~~~ ^
7 errors generated.
emcc2: error: 'D:/1installfiles/unity/Editor/2021.3.12f1c1/Editor/Data/PlaybackEngines/WebGLSupport/BuildTools/Emscripten/llvm\clang++.exe -target wasm32-unknown-emscripten -DEMSCRIPTEN -fno-inline-functions -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=2 -D__EMSCRIPTEN_minor__=0 -D__EMSCRIPTEN_tiny__=19 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=D:\1installfiles\unity\Editor\2021.3.12f1c1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten\emscripten\cache\sysroot -Xclang -iwithsysroot/include\compat -D__webgl__ -Wno-c++11-extensions -Wno-nonportable-include-path -ffunction-sections -fno-unwind-tables -fomit-frame-pointer -fno-threadsafe-statics -std=c++11 -Wno-#warnings -Wswitch -Wno-trigraphs -Wno-tautological-compare -Wno-invalid-offsetof -Wno-implicitly-unsigned-literal -Wno-integer-overflow -Wno-shift-negative-value -Wno-unknown-attributes -Wno-implicit-function-declaration -Wno-null-conversion -Wno-missing-declarations -Wno-unused-value -Wno-pragma-once-outside-header -fvisibility=hidden -fexceptions -fno-rtti -fno-strict-overflow -ffunction-sections -fdata-sections -fmessage-length=0 -pipe -DBASELIB_INLINE_NAMESPACE=il2cpp_baselib -DIL2CPP_MONO_DEBUGGER_DISABLED -DRUNTIME_IL2CPP -DGC_NOT_DLL -DIL2CPP_DEFAULT_DATA_DIR_PATH=Data -DNDEBUG -I. -ID:/1installfiles/unity/Editor/2021.3.12f1c1/Editor/Data/il2cpp/libil2cpp/pch -ID:/1installfiles/unity/Editor/2021.3.12f1c1/Editor/Data/il2cpp/libil2cpp -ID:/1installfiles/unity/Editor/2021.3.12f1c1/Editor/Data/il2cpp/external/baselib/Include -ID:/1installfiles/unity/Editor/2021.3.12f1c1/Editor/Data/il2cpp/external/baselib/Platforms/WebGL/Include -ID:/1installfiles/unity/Editor/2021.3.12f1c1/Editor/Data/il2cpp/external/bdwgc/include -Oz -fcolor-diagnostics -fdiagnostics-absolute-paths -UGC_THREADS -UUSE_MMAP -UUSE_MUNMAP -c -xc++ Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/ipux_Generic0.lump.cpp -o Library/Bee/artifacts/WebGL/il2cpp/master_WebGL_wasm/9tk2_eric0.lump.o' failed (1)
I tried to change settings in player settings\seeting for webgl. But it didn't work.
I'm trying to build build NUMBA package form its source to generate a wheel out of it. I know there is a wheel for windows but I want to do some test on my local Windows 64X machine. I have installed NUMPY, LLVMLITE dependencies and I'm using MinGW c++ compiler and not visual studio. I get a below error, what am I missing here?
py : C:\Workspace\Python_Runtime\Python\lib\site-packages\setuptools\distutils_patch.py:25:
UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.In Zeile:1 Zeichen:1
+ py setup.py bdist_wheel 2>&1 > error.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (C:\Workspace\Py...tuptools first.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
warnings.warn(TBB not found Using OpenMP from: True running bdist_wheel running build got version from file C:\Workspace\Python_Runtime\numba-0.54.1\numba/_version.py {'version': '0.54.1', 'full': '39aef3deb073a67b0bf121e099ecf5b33d799f40'}
running build_py
running build_ext
building 'numba._dispatcher' extension
C compiler: gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes
compile options: '-D__MSVCRT_VERSION__=0x1927 -
IC:\\Workspace\\Python_Runtime\\Python\\lib\\site-packages\\numpy\\core\\include -
IC:\Workspace\Python_Runtime\Python\include -IC:\Workspace\Python_Runtime\Python\include -c'
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -D__MSVCRT_VERSION__=0x1927 -
IC:\\Workspace\\Python_Runtime\\Python\\lib\\site-packages\\numpy\\core\\include -
IC:\Workspace\Python_Runtime\Python\include -IC:\Workspace\Python_Runtime\Python\include -c
numba/_dispatcher.cpp -o build\temp.win-amd64-3.9\Release\numba\_dispatcher.o
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -D__MSVCRT_VERSION__=0x1927 -
IC:\\Workspace\\Python_Runtime\\Python\\lib\\site-packages\\numpy\\core\\include -
IC:\Workspace\Python_Runtime\Python\include -IC:\Workspace\Python_Runtime\Python\include -c numba/_hashtable.c -o build\temp.win-amd64-3.9\Release\numba\_hashtable.o
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -D__MSVCRT_VERSION__=0x1927 -
IC:\\Workspace\\Python_Runtime\\Python\\lib\\site-packages\\numpy\\core\\include -
IC:\Workspace\Python_Runtime\Python\include -IC:\Workspace\Python_Runtime\Python\include -c numba/core/typeconv/typeconv.cpp -o build\temp.win-amd64 3.9\Release\numba\core\typeconv\typeconv.o
gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -D__MSVCRT_VERSION__=0x1927 -
IC:\\Workspace\\Python_Runtime\\Python\\lib\\site-packages\\numpy\\core\\include -
IC:\Workspace\Python_Runtime\Python\include -IC:\Workspace\Python_Runtime\Python\include -c numba/_typeof.c -o build\temp.win-amd64-3.9\Release\numba\_typeof.o
cc1plus.exe: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
cc1plus.exe: warning: command line option '-Wstrict-prototypes' is valid for C/ObjC but not for C++
numba/_hashtable.c:102:1: warning: '_Numba_hashtable_hash_int' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_hash_int(const void *key)
^
numba/_hashtable.c:108:1: warning: '_Numba_hashtable_hash_ptr' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_hash_ptr(const void *key)
^
numba/_hashtable.c:114:1: warning: '_Numba_hashtable_compare_direct' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_compare_direct(const void *key, const _Numba_hashtable_entry_t *entry)
^
numba/_hashtable.c:133:1: warning: '_Numba_hashtable_new_full' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_new_full(size_t data_size, size_t init_size,
^
numba/_hashtable.c:178:1: warning: '_Numba_hashtable_new' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_new(size_t data_size,
^
numba/_hashtable.c:188:1: warning: '_Numba_hashtable_size' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_size(_Numba_hashtable_t *ht)
^
numba/_hashtable.c:259:1: warning: '_Numba_hashtable_get_entry' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_get_entry(_Numba_hashtable_t *ht, const void *key)
^
numba/_hashtable.c:312:1: warning: '_Numba_hashtable_set' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_set(_Numba_hashtable_t *ht, const void *key,
^
numba/_hashtable.c:354:1: warning: '_Numba_hashtable_get' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_get(_Numba_hashtable_t *ht, const void *key, void *data, size_t data_size)
^
numba/_hashtable.c:368:1: warning: '_Numba_hashtable_pop' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_pop(_Numba_hashtable_t *ht, const void *key, void *data, size_t data_size)
^
numba/_hashtable.c:377:1: warning: '_Numba_hashtable_delete' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_delete(_Numba_hashtable_t *ht, const void *key)
^
numba/_hashtable.c:391:1: warning: '_Numba_hashtable_foreach' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_foreach(_Numba_hashtable_t *ht,
^
numba/_hashtable.c:451:1: warning: '_Numba_hashtable_clear' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_clear(_Numba_hashtable_t *ht)
^
numba/_hashtable.c:470:1: warning: '_Numba_hashtable_destroy' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_destroy(_Numba_hashtable_t *ht)
^
numba/_hashtable.c:491:1: warning: '_Numba_hashtable_copy' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
_Numba_hashtable_copy(_Numba_hashtable_t *src)
^
In file included from C:/Program Files/R/Rtools/mingw_64/x86_64-w64 mingw32/include/c++/cassert:43:0,
from numba/_dispatcher.cpp:5:
numba/_dispatcher.cpp: In function 'PyObject* call_cfunc(Dispatcher*, PyObject*, PyObject*, PyObject*, PyObject*)':
numba/_dispatcher.cpp:383:41: warning: suggest parentheses around comparison in operand of '|' [-Wparentheses]
assert(PyCFunction_GET_FLAGS(cfunc) == METH_VARARGS | METH_KEYWORDS);
^
g++ -g -shared build\temp.win-amd64-3.9\Release\numba\_dispatcher.o build\temp.win-amd64 3.9\Release\numba\_hashtable.o build\temp.win-amd64-3.9\Release\numba\_typeof.o build\temp.win amd64-3.9\Release\numba\core\typeconv\typeconv.o -
LC:\\Workspace\\Python_Runtime\\Python\\lib\\site-packages\\numpy\\core\\lib -
LC:\Workspace\Python_Runtime\Python\libs -LC:\Workspace\Python_Runtime\Python\PCbuild\amd64 -lnpymath -lpython39 -o build\lib.win-amd64-3.9\numba\_dispatcher.cp39-win_amd64.pyd build\temp.win-amd64-3.9\Release\numba\_typeof.o: In function `typecode_using_fingerprint': C:\Workspace\Python_Runtime\numba-0.54.1/numba/_typeof.c:617: undefined reference to `__imp__Numba_hashtable_get'
C:\Workspace\Python_Runtime\numba-0.54.1/numba/_typeof.c:639: undefined reference to `__imp__Numba_hashtable_set' build\temp.win-amd64-3.9\Release\numba\_typeof.o: In function `typeof_init':
C:\Workspace\Python_Runtime\numba-0.54.1/numba/_typeof.c:1115: undefined reference to `__imp__Numba_hashtable_new'
collect2.exe: error: ld returned 1 exit status
error: Command "g++ -g -shared build\temp.win-amd64-3.9\Release\numba\_dispatcher.o build\temp.win-amd64-3.9\Release\numba\_hashtable.o build\temp.win-amd64 3.9\Release\numba\_typeof.o build\temp.win-amd64-3.9\Release\numba\core\typeconv\typeconv.o
-LC:\\Workspace\\Python_Runtime\\Python\\lib\\site-packages\\numpy\\core\\lib -
LC:\Workspace\Python_Runtime\Python\libs -LC:\Workspace\Python_Runtime\Python\PCbuild\amd64 -lnpymath -lpython39 -o build\lib.win-amd64-3.9\numba\_dispatcher.cp39-win_amd64.pyd" failed with
exit status 1
I'm trying to compile a recent version of openssl on an optware-ng install with gcc 7.2.0 on x86_64 architecture
The system has 2 libpthreads, one in /lib:/usr/lib:/lib64:/usr/lib64 (link to each other). And one in the optware-ng install in /opt/lib:/opt/lib64 (also link to each other)
Compiling goes fine, but at link time I get the following error:
gcc -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. -o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o apps/libapps.a -lssl -lcrypto -ldl -pthread
./libcrypto.so: undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
Adding -v to the output of gcc:
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/lto-wrapper
Target: x86_64-buildroot-linux-gnu
Configured with: ../gcc-7.2.0/configure --build=x86_64-pc-linux-gnu --host=x86_64-buildroot-linux-gnu --target=x86_64-buildroot-linux-gnu --prefix=/opt --disable-nls --disable-static --with-as=/opt/bin/as --with-ld=/opt/bin/ld --enable-languages=c,c++,go --disable-multilib --disable-werror --with-gxx-include-dir=/opt/include/c++/7.2.0 --disable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --enable-libquadmath --enable-tls --disable-libmudflap --enable-threads --without-isl --without-cloog --disable-decimal-float --with-arch=nocona --enable-shared --disable-libgomp --with-gmp=/home/jenkins/Optware-ng/buildroot-x86_64/staging/opt --with-mpfr=/home/jenkins/Optware-ng/buildroot-x86_64/staging/opt --with-mpc=/home/jenkins/Optware-ng/buildroot-x86_64/staging/opt --with-system-zlib
Thread model: posix
gcc version 7.2.0 (GCC)
COMPILER_PATH=/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/:/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/:/opt/libexec/gcc/x86_64-buildroot-linux-gnu/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/bin/
LIBRARY_PATH=/opt/lib64/../lib64/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/lib64/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib/:/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-pthread' '-m64' '-Wall' '-O3' '-L.' '-o' 'apps/openssl' '-pthread' '-mtune=generic' '-march=nocona'
/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/collect2 -plugin /opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/liblto_plugin.so -plugin-opt=/opt/libexec/gcc/x86_64-buildroot-linux-gnu/7.2.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cc5Txvvm.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --eh-frame-hdr -m elf_x86_64 -dynamic-linker /opt/lib64/ld-linux-x86-64.so.2 -o apps/openssl /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib/crt1.o /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib/crti.o /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/crtbegin.o -L. -L/opt/lib64/../lib64 -L/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0 -L/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/lib64 -L/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib -L/opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../.. -rpath=/opt/lib64 apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o apps/libapps.a -lssl -lcrypto -ldl -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/crtend.o /opt/lib/gcc/x86_64-buildroot-linux-gnu/7.2.0/../../../../x86_64-buildroot-linux-gnu/lib/crtn.o
./libcrypto.so: undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
which seem to indicate in LIBRARY_PATH that it is first looking in /opt/lib64, which should be ok.
The output of
nm -g /opt/lib64/libpthread.so | grep pthread_atfork
000000000000edd0 T pthread_atfork#GLIBC_2.2.5
indicates that the method should be there.
The following piece of C code, creates the same link issue on this system, but compiles/links fine on other systems:
// compile with: gcc -pthread mycode.c
#include <stdio.h>
#include <pthread.h>
int main() {
pthread_t f2_thread, f1_thread;
void *f2(), *f1(), prepare();
int i1,i2;
i1 = 1;
i2 = 2;
// int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
pthread_create(&f1_thread,NULL,f1,&i1);
pthread_atfork(&prepare,NULL,NULL);
pthread_create(&f2_thread,NULL,f2,&i2);
pthread_join(f1_thread,NULL);
pthread_join(f2_thread,NULL);
}
void prepare() {
printf("prepare");
}
void *f1(int *x) {
int i;
i = *x;
sleep(1);
printf("f1: %d",i);
pthread_exit(0);
}
void *f2(int *x){
int i;
i = *x;
sleep(1);
printf("f2: %d",i);
pthread_exit(0);
}
It seems to me that gcc is somehow still using the /lib version, but I'm stuck.
I've tried adding
-Wl,-rpath=/opt/lib64
But it doesn't help. Any suggestions?
I have project structure like this,
a.pb.h --- includes --> protobuf.h
b.grpc.pb.h --- includes --> a.pb.h & grpcpp.h
Also there are a.pb.cc and b.grpc.cc files.
A C++ wrapper with extern C which is wrapper.cc and wrapper.h which includes b.grpc.pb.h and grpcpp.h.
The function inside extern C is char* helloWorld(const char*, const char*, const char*);
Creating .o of a.pb.h and b.grpc.pb.h:
g++ -fpic -std=c++11 `pkg-config --cflags protobuf grpc` -c -o a.pb.o a.pb.cc
g++ -fpic -std=c++11 `pkg-config --cflags protobuf grpc` -c -o b.grpc.pb.o b.grpc.pb.cc
Steps to create libcombined.so:
The grpc and protobuf so are already provided under /usr/local/lib.
First created .so of a.pb.o and b.grpc.pb.o to compile wrapper file as:
g++ -shared -o libcombined.so *.o
Compiled wrapper as:
g++ -fpic wrapper.cc -l:./libcombined.so -c -o wrapper.o -std=c++11
.so of a.pb.o, b.grpc.pb.o and wrapper.o as libcombined.so:
g++ -shared -o libcombinedwrapper.so *.o
Compiled main.c as:
gcc main.c -l:./libcombinedwrapper.so -o main -ldl
I am calling helloWorld from my main.c file which is:
#include <stdio.h>
#include <dlfcn.h>
int main(){
char* (*fn)(const char*,const char*,const char*);
void *handle = dlopen("path_to/libcombined.so",RTLD_NOW);
if(handle==NULL){
fprintf(stderr, "Error: %s\n", dlerror());
}
fn = (char* (*)(const char*,const char*,const char*))dlsym(handle, "helloWorld");
if (!fn) {
/* no such symbol */
fprintf(stderr, "Error: %s\n", dlerror());
dlclose(handle);
return 0;
}
char* msg = fn("asd","asdas","asdasd");
printf("%s",msg);
return 0;
}
Error after executing: ./main
Error: path_to/libcombinedwrapper.so: undefined symbol: _ZN6google8protobuf2io20ZeroCopyOutputStream15WriteAliasedRawEPKvi
Error: ./main: undefined symbol: helloWorld
Segmentation fault (core dumped)
The first above error is from symbol from protobuf.h file.
Can someone please suggest what I am doing wrong while linking or is there something I am doing wrong in main.c file?
g++ -shared -o libcombined.so *.o
You need to also link in all dependencies of the objects (libgrpc here).
You can add -Wl,--no-allow-shlib-undefined to verify that libcombined.so is linking everything it needs.
P.S. To avoid core dump, you should exit or return once dlopen fails.
P.P.S. It is generally a very bad idea(TM) to link *.o. Use proper Makefile to avoid unnecessary compilations and explicitly list objects that you are intending to put into libcombined.so.
Hello stackoverflowers :)
For the last several hours I've been trying to compile+load a multiple file module. The compilation emits a strange warning and the module fails to load. Here are the module, Makefile, compilation output and dmesg.
header:
// header.h
#ifndef _HEADER_H
#define _HEADER_H
void do_module_func(void);
void do_other_func(void);
#endif
'main' module file:
//mymodule.c
#include <linux/module.h>
#include <linux/kernel.h>
#include "header.h"
void do_module_func(void)
{
printk(KERN_INFO "module_func\n");
}
static int mymodule_init(void)
{
printk(KERN_INFO "Hello world\n");
do_other_func();
return 0;
}
module_init(mymodule_init);
static void mymodule_exit(void)
{
printk(KERN_INFO "Goodbye, cruel world\n");
}
module_exit(mymodule_exit);
MODULE_LICENSE("GPL")
other c file, which calls do_module_func() that sits in the 'main' module
//other_file.c
#include "header.h"
#include <linux/kernel.h>
void do_other_func(void)
{
printk(KERN_INFO "other_func\n");
do_module_func();
}
Makefile
//Makefile
obj-m := mymodule.o
mymodule-objs := other_file.o
CROSS:=arm-unknown-linux-gnueabi-
KERNEL:= ~/work/linux-davinci-2.6.38/
ARCH:=arm
PWD:=$(shell pwd)
all:
$(MAKE) CROSS_COMPILE=$(CROSS) ARCH=$(ARCH) -C $(KERNEL) M=$(PWD) modules
clean:
$(MAKE) CROSS_COMPILE=$(CROSS) ARCH=$(ARCH) -C $(KERNEL) M=$(PWD) clean
I'm cross compiling but I believe this shouldn't be a problem.
make output:
make CROSS_COMPILE....
make[1]: Entering directory .../linux-davinci-2.6.38
CC [M] .../other_file.o
LD [M] .../mymodule.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "do_module_func" [.../mymodule.o] undefined! <--- warning here
CC .../mymodule.mod.o
LD [M] .../mymodule.ko
make[1]: Leaving directory .../linux-davinci-2.6.38
insmod output:
can't insert 'mymodule.ko': unknown symbol in module, or unknown parameter
dmesg:
mymodule: Unknown symbol do_mdule_func (err 0)
Thus the module compiles with a (linkage?) warning and the module doesn't load.
Now, I see that in the make output there appears to be a linkage attempt after compiling other_file.c, but shouldn't there be a compilation of also mymodule.c before the linkage?
Thanks! :)
Turns out the problem was in the Makefile. The 'trick' is that you define in obj-m the module that will be compiled (into a .ko) and in the -objs you write all the source files.
Thus the definitions in this Makefile turn to:
obj-m := moduleko.o
moduleko-objs := other_file.o mymodule.o
and this is compiled into moduleko.ko.
This is because file_2 required file_1 symbol reference for building file_2 as LKM.
To overcome this, build file_1(LKM) and place the Module.symvers of file_1 in file_2 location. And build the file_2 again.
all:
$(MAKE) CROSS_COMPILE=$(CROSS) ARCH=$(ARCH) -C $(KERNEL) M=$(PWD) modules
instead try like this
$(MAKE) -C $(KERNEL) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS) M=$(PWD) /
this will run each file and links with object.hope this would solve your problem