I try to build my dynamic library project in linux. I build my qt library in static. But if i use it to build my proj, qt creator builds only libname.a file. However if i use original qt library qt creator builds libname.so file. Wats is the problem?
Pro file.
`#------------------------------------------------- # #
Project created by QtCreator 2020-10-22T07:46:59
# #-------------------------------------------------
QT -= gui TARGET = up_api_send
TEMPLATE = lib
DEFINES += UP_API_SEND_LIBRARY
DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += up_api_send.cpp
HEADERS += up_api_send.h\
up_api_send_global.h
unix { target.path = /usr/lib INSTALLS += target }
unix:!macx: LIBS += -L$$PWD/libplot/ -lplot2
INCLUDEPATH += $$PWD/headerplot
DEPENDPATH += $$PWD/headerplot`
Build log.
Original library.
16:04:07: Start build project up_api_send...
16:04:07: Starts: «/opt/Qt5.7.1/5.7/gcc_64/bin/qmake» /root/QT/QT_SO/up_api_send/up_api_send.pro -spec linux-g++
Info: creating stash file /root/QT/QT_SO/build-up_api_send-Desktop_Qt_5_7_1_GCC_64bit-Release/.qmake.stash
16:04:07: Процесс «/opt/Qt5.7.1/5.7/gcc_64/bin/qmake» success.
16:04:07: Starts: «/usr/bin/make» qmake_all
make: Target `qmake_all' action is not required.
16:04:07: Process «/usr/bin/make» success.
16:04:07: Starts: «/usr/bin/make»
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I../up_api_send -I. -I../up_api_send/headerplot -I/opt/Qt5.7.1/5.7/gcc_64/include -I/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -I. -I/opt/Qt5.7.1/5.7/gcc_64/mkspecs/linux-g++ -o up_api_send.o ../up_api_send/up_api_send.cpp
../up_api_send/up_api_send.cpp: In member function ‘bool DgateTrans::PLOT_sendMsg(const char*, const char*, int)’:
../up_api_send/up_api_send.cpp:143:19: warning: unused variable ‘tid’ [-Wunused-variable]
/opt/Qt5.7.1/5.7/gcc_64/bin/moc -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I/opt/Qt5.7.1/5.7/gcc_64/mkspecs/linux-g++ -I/root/QT/QT_SO/up_api_send -I/root/QT/QT_SO/up_api_send/headerplot -I/opt/Qt5.7.1/5.7/gcc_64/include -I/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -I. -I/usr/include/c++/4.7 -I/usr/include/c++/4.7/x86_64-linux-gnu -I/usr/include/c++/4.7/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../up_api_send/up_api_send.h -o moc_up_api_send.cpp
g++ -c -pipe -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I../up_api_send -I. -I../up_api_send/headerplot -I/opt/Qt5.7.1/5.7/gcc_64/include -I/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -I. -I/opt/Qt5.7.1/5.7/gcc_64/mkspecs/linux-g++ -o moc_up_api_send.o moc_up_api_send.cpp
rm -f libup_api_send.so.1.0.0 libup_api_send.so libup_api_send.so.1 libup_api_send.so.1.0
g++ -Wl,-O1 -Wl,-rpath,/opt/Qt5.7.1/5.7/gcc_64/lib -shared -Wl,-soname,libup_api_send.so.1 -o libup_api_send.so.1.0.0 up_api_send.o moc_up_api_send.o -L/root/QT/QT_SO/up_api_send/libplot/ -lplot2 -L/opt/Qt5.7.1/5.7/gcc_64/lib -lQt5Core -lpthread
ln -s libup_api_send.so.1.0.0 libup_api_send.so
ln -s libup_api_send.so.1.0.0 libup_api_send.so.1
ln -s libup_api_send.so.1.0.0 libup_api_send.so.1.0
16:04:09: Process «/usr/bin/make» success.
16:04:09: Time passed: 00:02.
Build log. Static library.
16:05:00: Start build project up_api_send...
16:05:00: Settings not changed, stage qmake is skipped.
16:05:00: Starts: «/usr/bin/make»
g++ -c -pipe -O2 -fPIC -std=gnu++11 -Wall -W -D_REENTRANT -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I../up_api_send -I. -I../up_api_send/headerplot -I/usr/local/Qt-5.7.1/include -I/usr/local/Qt-5.7.1/include/QtCore -I. -I/usr/local/Qt-5.7.1/mkspecs/linux-g++ -o up_api_send.o ../up_api_send/up_api_send.cpp
../up_api_send/up_api_send.cpp: In member function ‘bool DgateTrans::PLOT_sendMsg(const char*, const char*, int)’:
../up_api_send/up_api_send.cpp:143:19: warning: unused variable ‘tid’ [-Wunused-variable]
/usr/local/Qt-5.7.1/bin/moc -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I/usr/local/Qt-5.7.1/mkspecs/linux-g++ -I/root/QT/QT_SO/up_api_send -I/root/QT/QT_SO/up_api_send/headerplot -I/usr/local/Qt-5.7.1/include -I/usr/local/Qt-5.7.1/include/QtCore -I. -I/usr/include/c++/4.7 -I/usr/include/c++/4.7/x86_64-linux-gnu -I/usr/include/c++/4.7/backward -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include -I/usr/local/include -I/usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed -I/usr/include/x86_64-linux-gnu -I/usr/include ../up_api_send/up_api_send.h -o moc_up_api_send.cpp
g++ -c -pipe -O2 -fPIC -std=gnu++11 -Wall -W -D_REENTRANT -DUP_API_SEND_LIBRARY -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_CORE_LIB -I../up_api_send -I. -I../up_api_send/headerplot -I/usr/local/Qt-5.7.1/include -I/usr/local/Qt-5.7.1/include/QtCore -I. -I/usr/local/Qt-5.7.1/mkspecs/linux-g++ -o moc_up_api_send.o moc_up_api_send.cpp
rm -f libup_api_send.a
ar cqs libup_api_send.a up_api_send.o moc_up_api_send.o
16:05:02: Process «/usr/bin/make» success.
16:05:02: Time passed: 00:02.
Maybe i wrote wrong parameters when build qt library?
./configure -platform linux-g++
-release
-static
-fontconfig
-opensource
-confirm-license
-gtkstyle
-no-webkit
-nomake demos
-nomake examples
Related
There are several questions about compiler options. Now I use the following:
-target i386-windows-gnu -mno-sse -c -O3
-target x86_64-windows-gnu -mcx16 -c -O3
-target i386-linux-gnu -mno-sse -c -O3
-target x86_64-linux-gnu -mcx16 -c -O3
-target i386-darwin-gnu -mno-sse -fomit-frame-pointer -c -O3
-target x86_64-macos-gnu -fomit-frame-pointer -c -O3
-target armv7-none-linux-androideabi -mfpu=neon -mfloat-abi=hard -mthumb -fPIC -c -O3
-target aarch64-linux-android -c -O3
-target armv7m-none-ios-gnueabi -mfpu=neon -mfloat-abi=hard -mthumb -c -O3
-target arm64-darwin-gnu -fno-stack-protector -c -O3
There are no complaints only on Linux/Android. For other platforms it gives a warning (https://godbolt.org/z/YhZ5uc):
clang-9: warning: argument unused during compilation: '--gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0' [-Wunused-command-line-argument]
Compiler returned: 0
ARM32 platforms do not support the preserve_most attribute (https://godbolt.org/z/SQRJB2):
<source>:2:21: warning: 'preserve_most' calling convention is not supported for this target [-Wignored-attributes]
void __attribute__((preserve_most)) proc_most(int* x);
But the biggest problem is that Mac/iOS does not support TLS variables (https://godbolt.org/z/6bqjby)!
__thread int x;
int test()
{
return x;
}
<source>:2:1: error: thread-local storage is not supported for the current target
I have tried to follow the tutorials from here to build training tools for Tesseract. I get this error.
depbase=`echo boxchar.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../.. -DNDEBUG -DPANGO_ENABLE_ENGINE -I../../src/api -I../../src/api -I../../src/ccmain -I../../src/ccutil -I../../src/ccstruct -I../../src/lstm -I../../src/arch -I../../src/viewer -I../../src/textord -I../../src/dict -I../../src/classify -I../../src/wordrec -I../../src/cutil -I/usr/local/include/leptonica -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/uuid -I/usr/include/libdrm -g -O2 -std=c++11 -MT boxchar.lo -MD -MP -MF $depbase.Tpo -c -o boxchar.lo boxchar.cpp &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../.. -DNDEBUG -DPANGO_ENABLE_ENGINE -I../../src/api -I../../src/api -I../../src/ccmain -I../../src/ccutil -I../../src/ccstruct -I../../src/lstm -I../../src/arch -I../../src/viewer -I../../src/textord -I../../src/dict -I../../src/classify -I../../src/wordrec -I../../src/cutil -I/usr/local/include/leptonica -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/uuid -I/usr/include/libdrm -g -O2 -std=c++11 -MT boxchar.lo -MD -MP -MF .deps/boxchar.Tpo -c boxchar.cpp -fPIC -DPIC -o .libs/boxchar.o
boxchar.cpp: In member function 'void tesseract::BoxChar::GetDirection(int*, int*) const':
boxchar.cpp:66:42: error: 'U_RIGHT_TO_LEFT_ISOLATE' was not declared in this scope
dir == U_ARABIC_NUMBER || dir == U_RIGHT_TO_LEFT_ISOLATE) {
^
make[1]: *** [boxchar.lo] Error 1
make[1]: Leaving directory `/home/vmuser/ocrd-train-master/tesseract-fd492062d08a2f55001a639f2015b8524c7e9ad4/src/training'
make: *** [training] Error 2
I looked at this Github comment here which states:
http://source.icu-project.org/repos/icu/tags/release-52-1/icu4c/source/common/unicode/uchar.h
http://source.icu-project.org/repos/icu/tags/release-50-1-2/icu4c/source/common/unicode/uchar.h
The training tools need icu version 52 and up. The icu version in RHEL & CentOS 7 is 50.
And from locate uchar.h I found that it resides in /usr/include/uchar.h and
/usr/include/unicode/uchar.h
I am not sure which file to change now. I don't know if it seems like a really stupid question
Thanks in Advance.
So, I finally figured it out myself:
download icu packages from:
http://download.icu-project.org/files/icu4c/
I used this file: http://download.icu-project.org/files/icu4c/59.1/icu4c-59_1-src.tgz
After that
tar zxf (tar file)
cd icu/source
make
sudo make install
After this in the Tesseract Directory
make training
sudo make training-install
I am trying to write a makefile that I can use on linux and mac that builds with an address sanitizer. This works on my vagrant instance:
CC = gcc
ASAN_FLAGS = -fsanitize=address -fno-omit-frame-pointer -Wno-format-security
ASAN_LIBS = -static-libasan
CFLAGS := -Wall -Werror --std=gnu99 -g3
LDFLAGS += -lpthread
all: hello
hello: tiny_queue.o hello.o
$(CC) -o $# $(CFLAGS) $(ASAN_FLAGS) $(CURL_CFLAGS) $^ $(LDFLAGS) $(CURL_LIBS) $(ASAN_LIBS)
This works on ubuntu/trusty64 but fails on my mac with
$ make
gcc -Wall -Werror --std=gnu99 -g3 -I/opt/X11/include -c -o hello.o hello.c
gcc -o hello -Wall -Werror --std=gnu99 -g3 -fsanitize=address -fno-omit-frame-pointer -Wno-format-security tiny_queue.o hello.o -lpthread -static-libasan
clang: error: unknown argument: '-static-libasan'
make: *** [hello] Error 1
Does anyone know how to write a compatible makefile for the mac and linux?
p.s. I'm very new to C, sorry if this question is super basic.
CC = gcc
ASAN_FLAGS = -fsanitize=address -fno-omit-frame-pointer -Wno-format-security
ASAN_LIBS = -static-libasan
CFLAGS := -Wall -Werror --std=gnu99 -g3
LDFLAGS += -lpthread
all: hello
hello: tiny_queue.o hello.o
$(CC) -o $# $(CFLAGS) $(ASAN_FLAGS) $(CURL_CFLAGS) $^ $(LDFLAGS) $(CURL_LIBS) $(ASAN_LIBS)
You should not specify an Asan library (or a UBsan library, for that matter). Since you are using the compiler driver to drive link, just use -fsanitize=address (this is the recommended way of doing it). Do not add -static-libasan. The compiler driver will add the proper libraries for you.
I built libssl.a and libcryto.a. But when I want to link my.so to it, I got this error:
Error:(130) undefined reference to 'BIO_new_dgram'
If I delete this call, I can compile it succeed.
Did I build the library of openssl in a wrong way?
BIO_new_dgram is in libcrypto.a:
nm libcrypto.a | grep BIO_new_dgram
0000081c T BIO_new_dgram
I configure Openssl with:
./config shared --openssldir=$install_dir --prefix=$install_dir
and link command:
/home/choury/bin/Android/android-sdk-linux/ndk-bundle/toolchains/llvm/prebuilt/l
inux-x86_64/bin/clang++ --target=aarch64-none-linux-android --gcc-toolchain=/ho
me/choury/bin/Android/android-sdk-linux/ndk-bundle/toolchains/aarch64-linux-andr
oid-4.9/prebuilt/linux-x86_64 --sysroot=/home/choury/bin/Android/android-sdk-lin
ux/ndk-bundle/platforms/android-21/arch-arm64 -fPIC -std=c++11 -Wall -fPIC -ggdb
-O0 -Wl,--build-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-und
efined -Wl,-z,noexecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -Wl,--build
-id -Wl,--warn-shared-textrel -Wl,--fatal-warnings -Wl,--no-undefined -Wl,-z,noe
xecstack -Qunused-arguments -Wl,-z,relro -Wl,-z,now -shared -Wl,-soname,my.so -o
$outpath/my.so $mypath/a.o $mypath/b.o $install_dir/lib/libssl.a $install_dir/li
b/libcrypto.a -ldl my.a -lz -llog -lm "/home/choury/bin/Android/android-sdk-linux
/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/libsupc++.a" "/home/
choury/bin/Android/android-sdk-linux/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9
/libs/arm64-v8a/libgnustl_shared.so"
I build the project with cmake, the Openssl part of it:
set(OPENSSL_INCLUDE_DIR ${OPENSSL_ROOT_DIR}/include)
set(OPENSSL_LIBRARIES ${OPENSSL_ROOT_DIR}/lib)
set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBRARIES}/libcrypto.a)
set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBRARIES}/libssl.a)
find_package(OpenSSL REQUIRED IMPORTED)
The OPENSSL_ROOT_DIR is set with $install_dir in build.gradle.
The linker in NDK is sensitive to the order of static libraries on command line. If libA.a depends on libB.a, the command line should be
clang++ … a.o b.o a/libA.a b/libB.a … -Llibs -lm -ldl -lz -llog -o libqq.so
here I assume libm.so, libdl.so, libz.so and liblog.so. Note that the following command is equivalent:
clang++ … a.o b.o -La -lA -Lb -lB … -Llibs -lm -ldl -lz -llog -o libqq.so
I was wondering if anyone had success in porting the Linux versions of the Mongoose web server or the Civetweb web server to FreeBSD. I've tried to do a Make, but there is a compatibility issue between Linux and BSD, in that it cannot find -ldl. I've seen reference to this in a google search, and the recommended solution is probably beyond my skill level.
Linux uses GNU make by default. Its makefiles tend to be incompatible with FreeBSD's make. So you need to install GNU make using the /usr/ports/devel/gmake port. The program is called gmake on FreeBSD.
So for mongoose, download the latest mongoose source from github.
Then install GNU make using the /usr/ports/devel/gmake port. Unpack mongoose;
> tar xf mongoose-5.3.tar.gz
> cd mongoose-5.3/examples
Then compile it;
> gmake
cc hello.c ../mongoose.c -o hello -W -Wall -I.. -pthread -g -pipe
perl mkdata.pl websocket.html > websocket_html.c
cc websocket.c websocket_html.c ../mongoose.c -o websocket -W -Wall -I.. -pthread -g -pipe
cc server.c ../mongoose.c -o server -W -Wall -I.. -pthread -g -pipe
cc post.c ../mongoose.c -o post -W -Wall -I.. -pthread -g -pipe
cc multi_threaded.c ../mongoose.c -o multi_threaded -W -Wall -I.. -pthread -g -pipe
cc upload.c ../mongoose.c -o upload -W -Wall -I.. -pthread -g -pipe
cc auth.c ../mongoose.c -o auth -W -Wall -I.. -pthread -g -pipe
Civetweb also compiles without errors using gmake.