I am using swig to implement C++ code with Python.
There seems to be some issue compiling the dynamic module.
g++ -fpic -c jmotif.h repair_wrap.cxx repair.cpp -/Users/U374235/AppData/Local/Continuum/anaconda3/envs/neuralnetwork/python3.5.6/
The result is that I'm getting an error -
g++.exe: error: unrecognized command line option '-/Users/U374235/AppData/Local/Continuum/anaconda3/envs/neuralnetwork/python3.5.6/'
I believe this issue is being caused due to my giving swig the wrong Python.h header address
My syntax was incorrect. I should have written -
g++ -fpic -c jmotif.h repair_wrap.cxx repair.cpp -IC:/Users/U374235/AppData/Local/Continuum/anaconda3/envs/neuralnetwork/python3.5.6/
Related
I've been trying to convert a cpp file to wasm without emscripten recently and I've been running with some errors, for example, when I run these commands:
clang++ --target=wasm32 -nostdlib -O3 -o public/main.o -c src/*.cpp
wasm-ld --no-entry --export-all --lto-O3 --allow-undefined --import-memory public/main.o -o public/main.wasm
it gives me this error:
wasm-ld: error: unknown file type public/main.o
Here are the versions of clang and lld that I currently have:
clang version 12.0.1
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/jp4r5v8pla63qam5w34jvfyfmq8p74am-clang-12.0.1/bin
LLD 12.0.1
Also, I'm running the code on replit
Thank you
Ok, with this commands it works :D
clang++ --target=wasm32 -emit-llvm -c -S -o public/files/main.ll src/main.cpp
llc -march=wasm32 -filetype=obj -o public/files/main.o public/files/main.ll
wasm-ld --no-entry --export-all -o public/main.wasm public/files/main.o
The only thing is that you need to create some new files (main.ll and main.o) but it doesn't matter.
The place where I obtained the solution is here: https://surma.dev/things/c-to-webassembly/index.html
It was really useful
I have just started experimenting with XDP in an VM. I tried to build for bpf and I face an error, how can I resolve this?
# clang -O2 -Wall -target bpf -c all_dropper.c -o dropper.o
error: unknown target triple 'bpf', please use -triple or -arch
This issue is resolved, I had to upgrade the clang version to 3.9.
I trying to build an open source LLVM plugin (https://github.com/HewlettPackard/Atlas).
But when I try to build using the llvm plugin I get an "error: unable to load plugin... undefined symbol: _ZNK4llvm12FunctionPass17createPrinterPassERNS_11raw_ostreamERKSs" (llvm::FunctionPass::createPrinterPass).
This is likely caused by the different ABI problem mentioned here: undefined symbol for self-built llvm opt?, but building the plugin with -D_GLIBCXX_USE_CXX11_ABI=0 does not solve the problem.
I have Ubuntu 16.04. I tried clang version 3.6, 3.8 and 3.9 and the problem persists.
Building: (with clang++3.6, 3.8, 3.9, with and without -stdlib=libstdc++, with and without -D_GLIBCXX_USE_CXX11_ABI=0)
clang++-3.9 -D_GLIBCXX_USE_CXX11_ABI=0 -c src/Instrumentation/NvmInstrumenter.cpp -I/usr/lib/llvm-3.9/include -fPIC -std=c++11
clang++-3.9 -D_GLIBCXX_USE_CXX11_ABI=0 -shared NvmInstrumenter.o -o NvmInstrumenter.so
clang++-3.9 -Xclang -load -Xclang ./NvmInstrumenter.so -o oo -c ./r.cpp
The last line results in the undefined symbol error.
Any help would be greatly appreciated. Even suggestions on which direction to continue looking will help. Thanks.
After some more investigation, I found that I didn't put "-fno-rtti" during compilation. http://llvm.1065342.n5.nabble.com/llvm-dev-Undefined-symbol-error-while-running-the-pass-td92634.html
I am trying to configure and make install package nap6.4 for tcl, but it fails in during "make" with the following error:
cc -shared -o libnap6.4.so cart_proj.o eval_tree.o function.o geometry.o land_flag.o land_flag_i.o linsys.o nap.o napChoice.o napDyad.o napDyadLib.o napImgNAO.o napInit.o napLib.o napMonad.o napParse.tab.o napParseLib.o napPolygon.o napSpatial.o nap_get.o nap_hdf.o nap_netcdf.o nap_ooc.o triangulate.o -L/usr/local/lib -lnetcdf -L/usr/local/lib -lmfhdf -ldf -ljpeg -lz -L/usr/local/lib -lproj -L. -ltclstub8.4 -ltkstub8.4 -lieee -lm -lX11
/usr/bin/ld: /usr/local/lib/libmfhdf.a(mfsd.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with - fPIC
/usr/local/lib/libmfhdf.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make: *** [libnap6.4.so] Error 1
So I was told to recompile with -fPIC, which I did in the following way from the terminal:
export CFLAGS=-fPIC
./configure --prefix/lib/ActiveTcl --enable-shared
make
but this does not work. I have also tried with --disable-shared, make clean, and
export CFLAGS="-fPIC -DHAVE_NETCDF"/ export CFLAGS="-fPIC" etc..
along with other not-working versions of CFLAGS.
So I am wondering how do I recompile with -fPIC? Is there some special syntax that I'm missing here?
Sage is supposed to be able to create compiled code using Cython. I have never been able to get this to work. The problem appears to be with my Sage installation, since compiling fails on the included example. I don't believe I did anything special during installation, but apparently I something wrong. The Sage tutorial says
In order to make your own compiled Sage code, give the file an .spyx extension (instead of .sage). If you are working with the command-line interface, you can attach and load compiled code exactly like with interpreted code (at the moment, attaching and loading Cython code is not supported with the notebook interface). The actual compilation is done “behind the scenes” without your having to do anything explicit. See $SAGE_ROOT/examples/programming/sagex/factorial.spyx for an example of a compiled implementation of the factorial function that directly uses the GMP C library. To try this out for yourself, cd to $SAGE_ROOT/examples/programming/sagex/, then do the following:
sage: load "factorial.spyx"
When I try I get the following message:
Compiling ./factorial.spyx...
Error compiling cython file:
Error compiling ./factorial.spyx:
running build
running build_ext
building '_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0' extension
creating build
creating build/temp.linux-i686-2.6
gcc -fno-strict-aliasing -g -O2 -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/csage/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/python2.6/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/lib/python2.6/site-packages/numpy/core/include -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/sage/ext/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/ -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/devel/sage/sage/gsl/ -I. -I/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local/include/python2.6 -c _home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.c -o build/temp.linux-i686-2.6/_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.o -w -O2
creating build/lib.linux-i686-2.6
gcc -pthread -shared build/temp.linux-i686-2.6/_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.o -L/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local//lib/ -L/home/wstein/build/sage-4.7.1/local/lib -lmpfr -lgmp -lgmpxx -lstdc++ -lpari -lm -lcurvesntl -lg0nntl -ljcntl -lrankntl -lgsl -lgslcblas -latlas -lntl -lcsage -lpython2.6 -o build/lib.linux-i686-2.6/_home_oliver_Desktop_sage_4_7_1_linux_32bit_ubuntu_10_04_lts_i686_Linux_examples_programming_sagex_factorial_spyx_0.so -L/home/oliver/Desktop/sage-4.7.1-linux-32bit-ubuntu_10.04_lts-i686-Linux/local//lib
/usr/bin/ld: cannot find -lstdc++ collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Any suggestions? Thanks.
Per DSM's comment, I reinstalled g++-multilib, and now everything works fine.