llvm module can not be found - llvm

I tried to follow the instructions in http://releases.llvm.org/2.6/docs/tutorial/JITTutorial1.html to have make my own function and produce llvm IR. However, executing
c++ -g tut1.cpp llvm-config --cxxflags --ldflags --libs core -o tut1, I am stopped by:
"llvm/Module.h": No such file or Directory.
Does anyone know how can I solve this problem?

2.6 is very old. Try newer LLVM and tutorial, like this one.

Related

WxWidgets with Mingw wx/msw/libraries.h: not found

I'm using Debian 11, I installed Mingw and built WxWidgets with the following command:
../configure --prefix=/usr/x86_64-w64-mingw32 --host=x86_64-w64-ming32 --build=x86_64-linux --with-msw && make && sudo make install
And I'm using the following command to build:
x86_64-w64-mingw32-g++ wx.cpp `wx-config --cxxflags --libs std,aui`
I receive the following error:
wx/msw/libraries.h: not found
But file exists at: /usr/x86_64-w64-mingw32/include/wx-3.2/wx/msw/libraries.h
Where am I going wrong?
PS: I don't use any kind of IDE.
Friends, it finally worked, that's what you said above, the wx-config that is linked to the terminal, is only for linux, what was with the compilation for Windows inside /usr/x86_64-w64-mingw32/bin /wx-config.
When I want to compile for linux I pass:
g++ wx.cpp `wx-config --cxxflags --libs std,aui`
When I go to Windows I pass:
x86_64-w64-mingw32-g++ wx.cpp `/usr/x86_64-w64-mingw32/bin/wx-config --cxxflags --libs std,aui`
PS: I had to copy some dlls to the application folder, but it all worked out.
Thank you very much for everyone's patience.

Trouble compiling code from LLVM Kaleidoscope tutorial

When I used g++ -std=c++17 toy.cpp -o toy to compile the toy.cpp file without the header #include "llvm/ADT/STLExtras.h" in the toy.cpp file, everything was fine and I produced a "working" binary file.
However, when I added the #include "llvm/ADT/STLExtras.h" line to the toy.cpp file and compile it with the command g++ -std=c++17 toy.cpp -o toy, the terminal crushed me with the following output:
-bash: llvm-config: command not found
toy.cpp:1:10: fatal error: 'llvm/ADT/STLExtras.h' file not found
#include "llvm/ADT/STLExtras.h"
The same thing still happens even if I used
"clang++ -g -O3 toy.cpp llvm-config --cxxflags --ldflags --system-libs --libs core -o toy"
instead of "clang++ -g -O3 toy.cpp llvm-config --cxxflag" in the tutorial. My guess is that there's something wrong with the llvm-config thing. It's been bothering me for a while, please teach me how to solve it.
Link to the toy.cpp code
The answer to this is "llvm-config" is not working as expected.
Just check with which llvm-config to figure out whether you got this program. (mine is /usr/local/opt/llvm#8/bin/llvm-config). Or you can install with brew install llvm.
By the way, I came up with the same issue lately on kaleidoscope tutorial (ch2), but I want to know why the #include "llvm/ADT/STLExtras.h fails after several attempts on $(llvm-config --cxxflags --ldflags), etc or we aren't able to compile following chapter's code simply by removing the header declaration when llvm include files are necessary.

Trouble with compiling .cc files to be used in Intel Hyperscan

I am a student currently working on a project to implement Intel Hyperscan for Virus Signature Scanning on Ubuntu 16.04.
On the system, I have gcc 5.4.0 and g++ 5.4.0.
Hyperscan uses CMake to "build" itself.
Having successfully build Hyperscan, I can't seem to be able to find a way to compile my own code for it. I also could not find any "proper" way of compiling code meant for Hyperscan online, hence I assumed g++ would be right. I have tried,
g++ -o -std=c++11 test test.cc $(pkg-config --cflags --libs libhs)
only for it to give the error: hs.h: No such file or directory
Hence I used,
g++ -o -std=c++11 test test.cc -I../hyperscan/src $(pkg-config --cflags --libs
libhs)
to get another error:
/usr/bin/ld: cannot find -lhs and collect2: error: ld returned 1 exit status
At this point, I am kind of lost and can't really progress with my project. Am I using g++ wrongly? Have I built Hyperscan incorrectly? Any tips or solutions would be greatly appreciated!
$(pkg-config --cflags --libs libhs) only works when library and related development files are installed on the system. Looks like you have source code of library, so first you need to build and install library itself, only then compile your test program.
Also, library may be available in standard repositories, then you maybe want to install it using something like "sudo apt install libhs-dev", however, if you have source code of particular version that you need to work with, or library is closed source and non-public, then the only way is to compile and install it manually. Refer to documentation, README, INSTALL files that may be supplied with library code and follow build and installation procedures described there.

Link errors when linking LLVM

So I'm following the LLVM Kaleidoscope tutorial (I have LLVM 3.4 on a Ubuntu 14.04 box) and I get a LOT of link errors like:
/test.cpp:542: undefined reference to `llvm::getGlobalContext()'
test.cpp:556: undefined reference to `llvm::Module::Module(llvm::StringRef, llvm::LLVMContext&)'
Even If I explicitly copy and paste the code listing from the website into a seperate file, I still get the errors.
I compile by doing
clang++ -g -O3 test.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core`
So I've done this:
dzur:~> cp ~/sources/llvm/examples/Kaleidoscope/Chapter3/toy.cpp .
dzur:~> clang++ -g toy.cpp `~/builds/build-llvm/Debug+Asserts/bin/llvm-config --cxxflags --ldflags --system-libs --libs core`
and it's working fine on my (also ubuntu) system. The llvm-config referenced there is my build of top of tree llvm. I haven't tried with one of the previous releases as I don't have them handy, but hopefully this helps.
I figured out that if I remove the --system-libs flag it will compile without issue. I know this will probably bring out other bugs but it solves this problem.

WxGTK won't link under Arch Linux

So I have this Wx application written in C++ that I've tested under Linux Mint, Ubuntu, and even Mac but under Arch Linux it doesn't seem to link correctly. I've installed the wxgtk library required and the compilation works fine but when it gets to the linking stage I get a lot of output saying that none of the Wx methods could be found. wx-config --libs output looks correct to me so I'm not sure what's causing the problem. I will post my Makefile if necessary but it seems this issue is only specific to Arch Linux so far.
Just in case anyone is bashing their head over this I changed the linker line from
g++ `wx-config --libs` -o $(OBJS)
to
g++ -o $(OBJS) `wx-config --libs`
The reason for this is detailed in rodrigo's comment below.