Link errors using Qt custom types instead of STL types in gsoap binding - c++

I'm developing a Qt C++ program which must send data to a web-service.
I have used gsoap (v2.8.111) to generate the data binding source code this way:
wsdl2h -v -c++ -t ./typemap.dat -o binding/DonaldDuck.h ./DonaldDuck.wsdl
wsdl2h -v -c++ -t ./typemap.dat -o binding/MickeyMouse.h ./MickeyMouse.wsdl
wsdl2h -v -c++ -t ./typemap.dat -o binding/DaisyDuck.h ./DaisyDuck.wsdl
wsdl2h -v -c++ -t ./typemap.dat -o binding/ScroogeMcDuck.h ./ScroogeMcDuck.wsdl
soapcpp2 -C -c++ -j -qDonaldDuck -dbinding binding/DonaldDuck.h
soapcpp2 -C -c++ -j -qMikeyMouse -dbinding binding/MickeyMouse.h
soapcpp2 -C -c++ -j -qDaisyDuck -dbinding binding/DaisyDuck.h
soapcpp2 -C -c++ -j -qScroogeMcDuck -dbinding binding/ScroogeMcDuck.h
wsdl2h -c++ -g -t ./typemap.dat -o ./binding/Common.h *.wsdl
soapcpp2 -C -c++ -r -n -i -L -j -dbinding ./binding/Common.h
If I use the typemap.dat configured for use of STL types I can successfully build and run the program.
But because I'm developing with Qt I would like to use Qt types (specially QString and QDateTime), so I changed the typemap.dat file as explained here https://www.genivia.com/doc/databinding/html/index.html.
With the new typemap.dat The generation using the same commands listed above was successful but during build a lot of multiple definitions are unexpectedly signaled.
I can't understand why this problem occurs, can anyone help me?
I am available to provide other information if needed.

Related

missing function: _ZN4CoreC1Ev when running a emscripten js compiled file

So here is my Makefile file:
webgl:
emcc -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["bmp","png", "jpeg", "jpg"]' -s USE_SDL_TTF=2 -c main.cpp -o build/index.o
emcc -O1 build/index.o -s LLD_REPORT_UNDEFINED -s ERROR_ON_UNDEFINED_SYMBOLS=0 -o build/index.js
Yes, I have been using SDL2 for my emscripten project and compiling it has the big error so I have added a -s LLD_REPORT_UNDEFINED -s ERROR_ON_UNDEFINED_SYMBOLS=0 to compile immediately without errors. After my attempt to build, it works but I can't run because of an error when I typed node index.js and pressing the Enter key.
missing function: _ZN4CoreC1Ev
Aborted(-1)
I searched up _ZN4CoreC1Ev on Google for solution but Your search - _ZN4CoreC1Ev - did not match any documents. it just said. Any solutions?

How to compile custom cpp files on Google Colab

I'm trying to replicate the result of this github repo using Google Colab since I don't want to install all the requirements on my local machine and to take advantage of the GPU on Google Colab
However, one of the things I need to do (as indicated in the repo's README) is to first compile a cpp makefile. The instruction of the makefile is included below. Obvious I can't follow this instruction since I don't know Google Colab's directories of ncvv, cudalib and tensorflow library
cd latent_3d_points/external
with your editor modify the first three lines of the makefile to point to
your nvcc, cudalib and tensorflow library.
make
Is there a way for me to compile the files included in the makefile (because those functions are needed to run the model) either using the makefile directly or compile each cpp file individually? I included the content of the makefile below to avoid having you to click around in the repo looking for it
nvcc = /usr/local/cuda-8.0/bin/nvcc
cudalib = /usr/local/cuda-8.0/lib64
tensorflow = /orions4-zfs/projects/optas/Virt_Env/tf_1.3/lib/python2.7/site-packages/tensorflow/include
all: tf_approxmatch_so.so tf_approxmatch_g.cu.o tf_nndistance_so.so tf_nndistance_g.cu.o
tf_approxmatch_so.so: tf_approxmatch_g.cu.o tf_approxmatch.cpp
g++ -std=c++11 tf_approxmatch.cpp tf_approxmatch_g.cu.o -o tf_approxmatch_so.so -shared -fPIC -I $(tensorflow) -lcudart -L $(cudalib) -O2 -D_GLIBCXX_USE_CXX11_ABI=0
tf_approxmatch_g.cu.o: tf_approxmatch_g.cu
$(nvcc) -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -c -o tf_approxmatch_g.cu.o tf_approxmatch_g.cu -I $(tensorflow) -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -O2
tf_nndistance_so.so: tf_nndistance_g.cu.o tf_nndistance.cpp
g++ -std=c++11 tf_nndistance.cpp tf_nndistance_g.cu.o -o tf_nndistance_so.so -shared -fPIC -I $(tensorflow) -lcudart -L $(cudalib) -O2 -D_GLIBCXX_USE_CXX11_ABI=0
tf_nndistance_g.cu.o: tf_nndistance_g.cu
$(nvcc) -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++11 -c -o tf_nndistance_g.cu.o tf_nndistance_g.cu -I $(tensorflow) -DGOOGLE_CUDA=1 -x cu -Xcompiler -fPIC -O2
clean:
rm tf_approxmatch_so.so
rm tf_nndistance_so.so
rm *.cu.o
You can use the bash like on your pc by adding %%bash in the colab's cells.
Example:
Cell one: write cpp file
%%writefile welcome.cpp
#include <iostream>
int main()
{
std::cout << "Welcome To AI with Ashok's Blog\n";
return 0;
}
Cell two: compile and run
%%bash
g++ welcome.cpp -o welcome
./welcome
You can also open the cpp file in colab's build-in text editor in order to enjoy correct highlights. It opens when you open a text file from the "Files" tab on the left and can be save with "ctr+s" shortcut.
You can install the required version of Cuda in google colab. For eg.
For Cuda 9.2 you can try
!apt-get --purge remove cuda nvidia* libnvidia-*
!dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 dpkg --purge
!apt-get remove cuda-*
!apt autoremove
!apt-get update
!wget https://developer.nvidia.com/compute/cuda/9.2/Prod/local_installers/cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64 -O cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.88-1_amd64.deb
!apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
!apt-get update
!apt-get install cuda-9.2
Similarly, you can find a way to install Cuda 8.2.
For gcc
!apt-get install -qq gcc-5 g++-5 -y
!ln -s /usr/bin/gcc-5
!ln -s /usr/bin/g++-5
!sudo apt-get update
!sudo apt-get upgrade
Then you can compile it or make it by running make, if your installation has a custom make file.
!make

How can I use mingw to build mkspiffs?

I'm trying to build mkspiffs for windows. It's a c/c++ project. I installed mingw, and added it to my path.
The README.md says to run
$ git submodule update --init
$ make dist
The make dist command gives me the following output:
File not found - *.c
cc -std=gnu99 -Os -Wall -mno-ms-bitfields -Itclap -Iinclude -Ispiffs/src -I. -D VERSION=\"0.2.3-6-g983970e\" -D SPIFFS_VERSION=\"0.3.7-5-gf5e26c4\" -D BUILD_CONFIG=\"\" -D BUILD_CONFIG_NAME=\"-generic\" -D __NO_INLINE__ -c -o spiffs/src/spiffs_cache.o spiffs/src/spiffs_cache.c
process_begin: CreateProcess(NULL, cc -std=gnu99 -Os -Wall -mno-ms-bitfields -Itclap -Iinclude -Ispiffs/src -I. -D VERSION=\"0.2.3-6-g983970e\" -D SPIFFS_VERSION=\"0.3.7-5-gf5e26c4\" -D BUILD_CONFIG=\"\" -D BUILD_CONFIG_NAME=\"-generic\" -D __NO_INLINE__ -c -o spiffs/src/spiffs_cache.o spiffs/src/spiffs_cache.c, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [spiffs/src/spiffs_cache.o] Error 2
I'm using mingw64.
C:\Users\peterkapteyn>where gcc
C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gcc.exe
I am a novice when it comes to building things from source/using makefiles and that sort of thing. Can anyone offer some insight into what's going on?

How to exclude C/C++ system headers when SublimeClang parses?

I'm using sublime text 2 to develop a tiny operating system (C and assembly based), and I must not use any C++ features. For example, I need to implement the 'stdio.h' myself, and need to define 'bool' too. But SublimeClang always tells me
Error - redeclaration of C++ built-in type 'bool'
When I write
typedef int bool;
And it will include the system's 'stdio.h' instead of mine.
Also, when building the project, the compiler options are like:
i386-elf-gcc -Ikern/init/ -fno-builtin -Wall -ggdb -m32 -gstabs -nostdinc -fno-stack-protector -Ilibs/ -Ikern/debug/ -Ikern/driver/ -Ikern/trap/ -Ikern/mm/ -Ikern/libs/ -Ikern/sync/ -c kern/init/entry.S -o obj/kern/init/entry.o
i386-elf-ld -m elf_i386 -nostdlib -T tools/kernel.ld -o bin/kernel obj/kern/init/entry.o obj/kern/init/init.o obj/kern/libs/readline.o obj/kern/libs/stdio.o obj/kern/debug/kdebug.o obj/kern/debug/kmonitor.o obj/kern/debug/panic.o obj/kern/driver/clock.o obj/kern/driver/console.o obj/kern/driver/intr.o obj/kern/driver/picirq.o obj/kern/trap/trap.o obj/kern/trap/trapentry.o obj/kern/trap/vectors.o obj/kern/mm/default_pmm.o obj/kern/mm/pmm.o obj/libs/printfmt.o obj/libs/string.o
i386-elf-ld -m elf_i386 -nostdlib -N -T tools/boot.ld obj/boot/bootasm.o obj/boot/bootmain.o -o obj/bootblock.o
So, how to use the most basic C functions when SublimeClang parses? I cannot google out any useful configuration file of SublimeClang that helps.

Android: Statically link against libstdc++

my program compiles nicely for Android, however when I try to copy it to the Android emulator, it gives the following error:
knight666#Katja-Linux /media/Data/Shared/Galaxians $ acpy Galaxians.android
Filename: 'Galaxians.android'
819 KB/s (420657 bytes in 0.501s)
link_image[1638]: 825 could not load needed library 'libstdc++.so.6' for '/system/sbin/Galaxians.android' (load_library[984]: Library 'libstdc++.so.6' not found)CANNOT LINK EXECUTABLE
acpy is a small script I wrote that does the following:
#!/bin/sh
FILEPATH=`dirname $1`
FILENAME=`basename $1 .c`
echo "Filename: '$FILENAME'"
adb push $FILEPATH/$FILENAME /system/sbin/$FILENAME
adb shell chmod 777 /system/sbin/$FILENAME
adb shell /system/sbin/$FILENAME
Here is how I build my application:
oem#androiddev /media/YoghurtGum/Tests/Galaxians $ sudo make
arm-none-linux-gnueabi-g++ -static-libgcc -g -Wall -Werror -O2 -w -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c src/Alien.cpp -o intermediate/Alien.o
arm-none-linux-gnueabi-g++ -static-libgcc -g -Wall -Werror -O2 -w -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c src/Bullet.cpp -o intermediate/Bullet.o
arm-none-linux-gnueabi-g++ -static-libgcc -g -Wall -Werror -O2 -w -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c src/Game.cpp -o intermediate/Game.o
arm-none-linux-gnueabi-g++ -static-libgcc -g -Wall -Werror -O2 -w -I ../../YoghurtGum/src/GLES -I ../../YoghurtGum/src -c src/Player.cpp -o intermediate/Player.o
arm-none-linux-gnueabi-gcc
-Wl,--entry=main,
-dynamic-linker=/system/bin/linker,
-rpath-link=/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib,
-rpath=../../YoghurtGum/lib/Android,
-L/home/oem/android-ndk-r3/build/platforms/android-5/arch-arm/usr/lib
-nostdlib
-lstdc++
intermediate/Alien.o
intermediate/Bullet.o
intermediate/Game.o
intermediate/Player.o
../../YoghurtGum/lib/Android/libstdc++.a
../../YoghurtGum/bin/YoghurtGum.a
-o bin/Galaxians.android
Line breaks are only for clarity, none exist in the actual output.
YoghurtGum is my game library that already statically and dynamically links to libstdc++.
When I remove lstdc++, the program doesn't compile because it can't find the library.
Is there a way to link to stdlibc++ statically or link the application to the correct dynamic library in the emulator?
Thanks in advance.
There is a modification of the ndk with support for exceptions, RTTI and stdlibc++.
http://www.crystax.net/android/ndk-r3.php
The other alternative involves porting just what you need, by hand... eek!