How do I link the static Stasm library to my program? - c++

Earlier I succesfully compiled Stasm using cmake on Ubuntu 13.10. It gave me the static library libstasm.a.
However, I'm trying to build my own program using Stasm code but every time I try g++ gives me this:
hanna#hanna-HP-650-Notebook-PC:~/Desktop$ g++ -Wall -L/home/hanna/Downloads/stasm4.1.0/build -lstasm stasmtest.cpp -o stasmtest
stasmtest.cpp:7:23: fatal error: stasm_lib.h: No such file or directory
#include "stasm_lib.h"
^
compilation terminated.
I tried compiling the Minimal.cpp example in the external library because that is supposed to show how to use Stasm in my own programs but still I get the same error.
Can someone please tell me what command I should use to link the Stasm library to my program?
Thanks in advance!

You get a compilation error, not a linking one. g++ cannot find the "stasm_lib.h" header. Use -I/path/to/stasm_lib.h as parameter to g++.

Related

c++ SDL2 - ld||cannot find -lmingw32|

I was creating program on windows with SDL2 and the program worked fine, but when I changed my os to linux mint (and install code::blocks, gcc, g++, SDL2), I run into troubles with compiling my code.
I have one error:
- ld||cannot find -lmingw32|
I guess that I don't have mingw32 library, where can I get it? Or is the problem diferent?
BTW: I also tryed to google it.
Thank for response.
Read the manual.
On linux you don't need -lmingw32. Instead, use
`sdl2-config --libs`
to get the list of all needed linker flags.
Example usage:
gcc -o myprogram myprogram.o `sdl2-config --libs`
Problem was solved by removing linker on mingw32 and lib rotozoom.h.

Error message while compiling a program

I’m a newbie to C++ and Linux. There is this code I’m playing with that requires me to install the HElib (Homomorphic encryption library and other libraries - GMP, NTL) which I did. I want to compile the code (main.cpp) that has a header file (FHE.h) in HElib. My problem is how can I link FHE.h (in HElib folder) and main.cpp (in another folder) together so that I can compile them. I have tried some commands
g++ -I/Home/HElib/src/FHE.h main.cpp -o main
Error message
main.cpp:1:17: fatal error: FHE.h: No such file or directory
compilation terminated.
Another command line
g++ -I/Home/HElib/Src/FHE.h -I/Home/SimpleFHESum-master/SimpleFHESum-master/main.cpp -o main]
Error Message
g++: fatal error: no input files
compilation terminated.
What's wrong and how can I fix this?
The -I flag adds the following directory to the include path of the compiler. This enables you to write e.g. #include "FHE.h" even though that file is not located in the same folder as the source file you're trying to compile.
Have you tried just removing the 'FHE.h' part from your -I directive?
g++ -I/Home/HElib/src ...

OpenBlas and g++

I have installed OpenBlas in TX1 and the time_dgemm example compiles fine with the gcc. However, I need to be able to link the rest of my code with OpenBlas using g++. When I try to compile the time_dgemm example with g++ it fails, giving the linking error "...undefined reference to 'dgemm_(......". The only change is using the g++ instead of gcc.
I have tried to compile the OpenBLAS library with g++ (make CC=g++), as other people suggested in the past, but the compilation fails when it tries to compile some part of BLAS.
Any ideas?
If some people have the same issue, I was able to compile with the following command:
g++ openBlasExample.cpp -I /usr/include/openblas -lopenblas
You can find your openblas include folder by using on Linux:
locate openblas
More info here:
https://gist.github.com/xianyi/6930656

Libc++ linked programs fail with symbol lookup error

I've recently built libc++ from scratch as my prject needs some features that are not yet implemnted in libstdc++.
I try to compile the hello world program located in src/main.cpp with line
clang -Wall -stdlib=libc++ -std=c++11 -c src/main.cpp -obuild/main.o
and the build suceeds
Then I link it with
clang -lc++ build/main.o -o qasix
and the linking suceeds too.
But when I run the program with
./qasix
I get the following error:
./qasix: symbol lookup error: /usr/local/lib/libc++.so.1: undefined symbol: _ZTVN10__cxxabiv120__si_class_type_infoE
I would like to know why this is occurring and also how to fix it.
I am on Xubuntu 13.10 if that's of any help.
PS: This problem popped up yesterday. Earlier other libc++ programs would compile fine.
This started when I did a debug build of a program with the -g flag and it compiled and ran fine, but all later programs complained about this symbol lookup failure. Please help.
it appears that you need the support library "libc++abi". It provides things like low-level exception support, type_info support, etc.
For Ubuntu (as opposed to Xubuntu), it appears that you can get it here: http://www.ubuntuupdates.org/package/core/saucy/universe/base/libc++abi-dev

How to add speech.h to g++ in Cygwin?

I'm just trying to compile a c++ program using the emulated g++ compiler in Cygwin on a Windows 7 machine that has the following includes:
iostream
string
windows.h
stdio.h
mmsystem.h
initguid.h
objbase.h
objerror.h
ole2ver.h
speech.h
It compiles them all fine with the exception of speech.h, which is sort of the bread and butter of what I'm working on, soo.. yeah.
Returns the following:
test.cpp:11:20: fatal error: speech.h: No such file or directory compilation terminated.
Any and all help will be much appreciated.
The files that do compile are on your system path, so the compiler can find them. speech.h isn't, so you have to tell it where to look:
g++ -c test.cpp -I<Path_to_speech.h>/speech.h ...
I.e. if it's in C:\Users\Kirk\test\include, then
g++ -c test.cpp -IC:/Users/Kirk/test/include/speech.h ...