Undefined reference to symbol __cxa_free_exception##CXXABI_1.3 - clang

Using clang to link a program fails like this:
/usr/bin/x86_64-pc-linux-gnu-ld: stackoverflow.o: undefined reference to symbol '__cxa_free_exception##CXXABI_1.3'

Like with gcc, you have to use clang++ to link C++ programs

Related

How to fix Unresolved external from FILE2.0?

I have some HDF5 C code that I am trying to port to C++Builder. I am getting this error at build time:
[ilink64 Error] Error: Unresolved external 'H5check_version' referenced from D:\DELPHITOOLS\PASHDF\C\WIN64\DEBUG\FILE2.O
H5check_version is included in H5public.h as a macro.
Why does C++Builder not find this?
H5check_version is included in H5public.h as a macro.
If that were true, you would not be getting a linker error, since macros are handled only during the preprocessor stage.
Somewhere in your project, the compiler is seeing a declaration of H5check_version as a function, and your file2 unit is calling it as a function, but the linker can't find the implementation of that function, hence the error.
Your project needs to contain a reference to the appropriate .lib file that either implements the actual function (static linking) or tells the linker which DLL the function is exported from (dynamic linking).
C/C++ is case sensitive, so H5check_version is different from H5Check_version.
AFAIK pascal is not case sensitive at all.
Regards

Load clang pass from within another pass

I have two LLVM passes, one which requires the outputs of the other. So in PassB I have:
void DiscoPoP::getAnalysisUsage(AnalysisUsage &Info) const{
Info.addRequired<PassA>();
}
I tried adding the snippet below to PassB, but when running clang -Xclang -load -Xclang LLVMPassB.so I get an error: undefined symbol: _ZN18PassA2IDE
static RegisterStandardPasses PassLoader(
PassManagerBuilder::EP_EarlyAsPossible,
[](const PassManagerBuilder &Builder,
legacy::PassManagerBase &PM) { PM.add(new PassA()); });
If I load PassA in clang as well, it works: clang -Xclang -load -Xclang LLVMPassA.so -Xclang -load -Xclang LLVMPassB.so
But it seems redundant to have to load it manually if it required from the PassB. Is there a way to load PassA programmatically from PassB?
I get an error: undefined symbol: _ZN18PassA2IDE
Because the PassA isn't visible to clang.
If I load PassA in clang as well, it works: clang -Xclang -load -Xclang LLVMPassA.so -Xclang -load -Xclang LLVMPassB.so
As expected.
But it seems redundant to have to load it manually if it required from the PassB.
Only if there was a way for clang know know about PassA when passB is supplied as flag. clang has no way of knowing where LLVMPassA.so resides unless we pass as flag.
Is there a way to load PassA programmatically from PassB?
This can be done if you modify the LLVM source code and put both your passes there. Registering a pass within LLVM pass manager is straightforward. See https://reviews.llvm.org/D50658 (Hot cold splitting pass) as an example, specifically changes in lib/Transforms/IPO/PassManagerBuilder.cpp, and function createHotColdSplittingPass.

std::variant gives std#bad_alloc in assignment operatoe

Rad Studio Rio 10.3.1, CLANG.
The simple code throws an exception in the assignment operator (y=x): 'std#bad_alloc'
typedef std::variant< std::string, int> MVariant;
MVariant x=10;
MVariant y;
y=x;
I cannot see the reason. What am I missing?
I think that the problem is not in Rad Studio itself. It is about CLANG. This is known bug 33222 that seems to only affect libstdc++'s std::variant (and other constructs using the same combination). The problem is related to friend function to templates.
The variant from libc++ doesn't seem to use the technique of friends that libstdc++ used.
See get<string> for variants fail under clang++ but not g++

ECDSA IN CONTIKI ERROR

Im trying to compile this file ecc-sign.c authored by you.
/home/user/Desktop/contiki-2.7/examples/cc2538-common/pka/ecc-sign.c
but what im getting is the errors below,
LD ecc-sign.z1
ecc-sign.co: In function `process_thread_ecdsa_sign_test':
ecc-sign.c:(.text+0x30): undefined reference to `pka_init'
ecc-sign.c:(.text+0x4a): undefined reference to `ecc_dsa_sign'
ecc-sign.c:(.text+0xd6): undefined reference to `ecc_compare'
ecc-sign.c:(.text+0x122): undefined reference to `ecc_compare'
ecc-sign.c:(.text+0x148): undefined reference to `pka_disable'
here is the make file in folder /home/user/Desktop/contiki-2.7/examples/cc2538-common/pka/
CONTIKI_PROJECT = ecc-ecdh ecc-sign ecc-verify
all: $(CONTIKI_PROJECT)
CONTIKI = ../../..
include $(CONTIKI)/Makefile.include
What is the hardware platform you are using?
LD ecc-sign.z1
If it's the Z1, the compilation fails, because this is example is based on the CC2538 chip, which supports hardware acceleration for ECDSA.
The Z1's MSP430 however doesn't and that's why it fails.

Compile OpenCV sample convert_cascade.cpp (OpenCV 2.3)

I'm running OpenCV 2.3.1 on Ubuntu 11.10. I can compile various program I've written myself wih no issue.
Now, however, I have a half-done Haar cascade, that I need to assemble into the xml-cascade file. For this purpose I need to use the included sample program convert_cascade.c. It is not compiled by default, so I need to do that.
Running gcc like this fails:
gcc -lopencv_core -lopencv_highgui -lopencv_objdetect -I/usr/local/include/opencv/ -L/usr/local/lib/ convert_cascade.c -o convert_cascade
It gives me the following errors:
/tmp/cc5UddX6.o: In function `cvRound':
convert_cascade.c:(.text+0x19): undefined reference to `lrint'
/tmp/cc5UddX6.o: In function `cvDecRefData':
convert_cascade.c:(.text+0xb3b): undefined reference to `cvFree_'
convert_cascade.c:(.text+0xbac): undefined reference to `cvFree_'
/tmp/cc5UddX6.o: In function `cvGetRow':
convert_cascade.c:(.text+0xca2): undefined reference to `cvGetRows'
/tmp/cc5UddX6.o: In function `cvGetCol':
convert_cascade.c:(.text+0xccd): undefined reference to `cvGetCols'
/tmp/cc5UddX6.o: In function `cvReleaseMatND':
convert_cascade.c:(.text+0xce0): undefined reference to `cvReleaseMat'
/tmp/cc5UddX6.o: In function `cvSubS':
convert_cascade.c:(.text+0xe00): undefined reference to `cvAddS'
/tmp/cc5UddX6.o: In function `cvCloneSeq':
convert_cascade.c:(.text+0xe4e): undefined reference to `cvSeqSlice'
/tmp/cc5UddX6.o: In function `cvSetNew':
convert_cascade.c:(.text+0xead): undefined reference to `cvSetAdd'
/tmp/cc5UddX6.o: In function `cvGetSetElem':
convert_cascade.c:(.text+0xf40): undefined reference to `cvGetSeqElem'
/tmp/cc5UddX6.o: In function `cvEllipseBox':
convert_cascade.c:(.text+0x1040): undefined reference to `cvEllipse'
/tmp/cc5UddX6.o: In function `cvFont':
convert_cascade.c:(.text+0x1090): undefined reference to `cvInitFont'
/tmp/cc5UddX6.o: In function `cvReadIntByName':
convert_cascade.c:(.text+0x111e): undefined reference to `cvGetFileNodeByName'
/tmp/cc5UddX6.o: In function `cvReadRealByName':
convert_cascade.c:(.text+0x11af): undefined reference to `cvGetFileNodeByName'
/tmp/cc5UddX6.o: In function `cvReadStringByName':
convert_cascade.c:(.text+0x1209): undefined reference to `cvGetFileNodeByName'
/tmp/cc5UddX6.o: In function `cvReadByName':
convert_cascade.c:(.text+0x1239): undefined reference to `cvGetFileNodeByName'
convert_cascade.c:(.text+0x124f): undefined reference to `cvRead'
/tmp/cc5UddX6.o: In function `main':
convert_cascade.c:(.text+0x13b6): undefined reference to `cvLoadHaarClassifierCascade'
convert_cascade.c:(.text+0x1495): undefined reference to `cvSave'
collect2: ld returned 1 exit status
It seems that all the missing functions areare old C-style OpenCV functions prototyped in core_c.h. But including that ( #include <opencv2/core/core_c.h> ) makes no difference. I also tried compiling with the -lopencv_legacy flag (basically just a guess that it might have something to do with older functions), to no avail.
What should I do in order to compile it?
There should be a build_all.sh script in the /samples/c/ directory that will build all the examples for you; no CMAKE tweaks required.
Nevermind. It turned out I had to recompile OpenCV anyway in order to enable TBB, so I simply gave CMAKE the BUILD_EXAMPLES=ON command, and now I have it in a compiled version. I'm pretty sure that is not the proper solution though ;-)

Resources