how to compile with llvm and g++? - c++

I use a fedora-11 system and recently I installed llvm ( sudo yum -y install llvm llvm-docs llvm-devel ).
When I search for llvm I get them in /usr/bin. Some of the links to the binaries are broken (llvm-gcc,llvm-g++,llvm-cpp,etc.). The include files are found within /usr/include/llvm and libs at /usr/lib/llvm. How to compile them using g++? I tried to compile the kaleidoscope code given in the tutorial as per directed, but it fails to compile.
I get this:
toy.cpp:5:30: error: llvm/LLVMContext.h: No such file or directory
toy.cpp:352: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp: In member function ‘virtual llvm::Value* NumberExprAST::Codegen()’:
toy.cpp:358: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp: In member function ‘virtual llvm::Value* BinaryExprAST::Codegen()’:
toy.cpp:379: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’
toy.cpp:379: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp: In member function ‘llvm::Function* PrototypeAST::Codegen()’:
toy.cpp:407: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’
toy.cpp:407: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp:408: error: ‘getDoubleTy’ is not a member of ‘llvm::Type’
toy.cpp: In member function ‘llvm::Function* FunctionAST::Codegen()’:
toy.cpp:454: error: ‘getGlobalContext’ was not declared in this scope
toy.cpp: In function ‘int main()’:
toy.cpp:543: error: ‘LLVMContext’ was not declared in this scope
toy.cpp:543: error: ‘Context’ was not declared in this scope
toy.cpp:543: error: ‘getGlobalContext’ was not declared in this scope
I cannot find the LLVMContext.h file too. So I guess this might be a version problem.
what should I do to make it work?
Some help would be good! thanks in advance... :)

Looks like the headers weren't installed or were installed in a path you aren't using. My suggestion would be to download the code from the llvm.org website or svn and use that to build up the Kaleidoscope example. It's fairly simple and all the code is in the examples directory.

Instead of using yum, install clang/llvm by following this, or this link.

Related

Declaring GnuplotHelper failed in ns3

I want to use GnuplotHelper in ns3 to plot the results. even when I run ns3's default example seventh.cc I get the following error:
../scratch/congestion.cc: In function ‘int main(int, char**)’:
../scratch/congestion.cc:173:1: error: ‘GnuplotHelper’ was not declared in this scope
GnuplotHelper plotHelper;
^
../scratch/congestion.cc:180:1: error: ‘plotHelper’ was not declared in this scope
plotHelper.ConfigurePlot ("Test","CongestionWindow vs. Time","Time (Seconds)","CongestionWindow","jpg");
^
../scratch/congestion.cc:181:81: error: ‘GnuplotAggregator’ has not been declared
plotHelper.PlotProbe (probeName,probeTrace,"CongetionWindow","CongestionWindow",GnuplotAggregator::KEY_BELOW);
If I include "gnuplot-helper.h" I get an additional line and same error:
../scratch/seventh.cc:24:28: fatal error: gnuplot-helper.h: No such file or directory
compilation terminated.
I've installed gnuplot on my linux. What should I do? How can I declare Gnuplot helper?
First, did you install a gnu-plot-dev package or just gnuplot? Many distributions separate the ability to use libraries and the ability to develop against them.
If you are sure the include files are actually on your system somewhere (check both /usr/include and /usr/local/include/) you may need to add an additional directory level to your compiler search path (perhaps /usr/include/gnuplot/ but I am only guessing there).
Try
#include "ns3/stats-module.h"

Sphinix GUI trainer Failed to compile

i am trying to create ASR system for my native language called amharic and my plan is to make an aquastic model without toomuch effort. for that i thought i could use ASTRA(Advanced Sphinix Trainer ) which is made using QT. but the thing is there is only source code , no compiled binaries and wheni try to compile it using QT 5.1 mingw (X64) i get this errors .
S:\Lite\astra\audio_play.cpp:-1: In member function 'void audio_play::pause()':
S:\Lite\astra\audio_play.cpp:31: error: 'SIGSTOP' was not declared in this scope
S:\Lite\astra\audio_play.cpp:31: error: 'kill' was not declared in this scope
S:\Lite\astra\audio_play.cpp:38: error: 'SIGCONT' was not declared in this scope
S:\Lite\astra\audio_play.cpp:38: error: 'kill' was not declared in this scope
S:\Lite\astra\audio_play.cpp:-1: In member function 'void audio_play::stop_record()':
S:\Lite\astra\audio_play.cpp:50: error: 'kill' was not declared in this scope
Source code location of ASTRA -- AStra Trainer

G++ not finding symbols from regex system header

I am trying to use the GNU C library regex functionality in my C++ project, particularly I'm trying to use the regex_t regcomp, regexec, regfree functions. Upon compilation I get errors stating that these symbols are undefined:
me> g++ -I/me/myheaders/ -c RootGenerator.cpp -o RootGenerator.o -std=gnu++0x -Wall
RootGenerator.cpp: In function ‘std::string findFirstFileInCurrentDirectory(std::string)’:
RootGenerator.cpp:1072: error: ‘regex_t’ was not declared in this scope
RootGenerator.cpp:1072: error: expected ‘;’ before ‘re’
RootGenerator.cpp:1073: error: ‘re’ was not declared in this scope
RootGenerator.cpp:1073: error: ‘REG_EXTENDED’ was not declared in this scope
RootGenerator.cpp:1073: error: ‘REG_NOSUB’ was not declared in this scope
RootGenerator.cpp:1073: error: ‘regcomp’ was not declared in this scope
RootGenerator.cpp:1074: error: expected ‘;’ before ‘int’
RootGenerator.cpp:1084: error: ‘status’ was not declared in this scope
RootGenerator.cpp:1084: error: ‘regexec’ was not declared in this scope
RootGenerator.cpp:1092: error: ‘REG_NOMATCH’ was not declared in this scope
RootGenerator.cpp:1108: error: ‘regfree’ was not declared in this scope
I realize that the regex header is a TR1 implementation and is therefore experimental for my version of GCC. I added the -std=gnu++0x compiler option according to the compiler warning recieved when first trying to compile but this doesn't seem to fix the issue. Is this an issue of the system not recognizing and adding paths to "experimental" headers? Are there additional include paths or compiler options that I need to specify?
As an additional note, I noticed in Eclipse/CDT that under the "includes" tab in the Project Explorer view, it shows a list of the system header paths. It lists many header files under the /user/include/c++/4.4.4 path tab, but It doesn't list the regex header. I think this is also reaffirming that there is a setting issue.
Found the problem:
#include <regex>
should be
#include <regex.h>
The regex.h header is the GNU C library implementation of regex, containing the functions I was trying to use in my source. The regex header is the TR1 (and incomplete) regex implemntation. So #Oli, I wasn't referencing the relevant header after all!

program with boost thread 1.51 doesn't build

I am trying to compile a program using boost thread with the latest version. I am using
gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)
With the 1.50 I had an issue saying that the reference to boost::thread::~thrad() couldn't be found. So I updated to the new one I got the following
/usr/local/include/boost/thread/detail/thread.hpp:65: error: expected ';' before 'thread_data'
/usr/local/include/boost/thread/detail/thread.hpp:68: error: expected `;' before 'thread_data'
/usr/local/include/boost/thread/detail/thread.hpp:88: error: expected ';' before 'thread_data'
/usr/local/include/boost/thread/detail/thread.hpp:91: error: expected `;' before 'void'
/usr/local/include/boost/thread/detail/thread.hpp:105: error: expected ';' before 'thread_data'
/usr/local/include/boost/thread/detail/thread.hpp:108: error: expected `;' before 'void'
/usr/local/include/boost/thread/detail/thread.hpp:121: error: expected ';' before 'private'
/usr/local/include/boost/thread/detail/thread.hpp:153: error: expected primary-expression before ')' token
/usr/local/include/boost/thread/detail/thread.hpp:153: error: there are no arguments to 'BOOST_THREAD_RV_REF' that depend on a template parameter, so a declaration of 'BOOST_THREAD_RV_REF' must be available
/usr/local/include/boost/thread/detail/thread.hpp:153: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/usr/local/include/boost/thread/detail/thread.hpp:153: error: expected `)' before 'f'
/usr/local/include/boost/thread/detail/thread.hpp:153: error: invalid in-class initialization of static data member of non-integral type 'boost::detail::thread_data_ptr'
/usr/local/include/boost/thread/detail/thread.hpp:153: confused by earlier errors, bailing out
I had no clue why is doing this way. Is there any workaround?
I had this same issue with g++ 4.2.1 on OSX, though I don't think its a compiler issue per se.
I had previously installed boost libraries and headers installed to /usr/local/lib and /usr/local/include by invoking b2 install. This works on a new installation, but it doesn't correctly overwrite a previous boost installation (I had 1.49). All I had to do was point my build at the boost build directory I was using, or to delete /usr/local/include/boost and run b2 install again. The first time I ran b2 install it only copied the libs which was fast, the second time it took much longer and copied over all the header files.

Is libssl version 0.9.8e compatible with 0.9.7a?

I'm using a third party static library in my C++ project that has a dependency on libssl version 0.9.7a. Due to various reasons, the libssl version that my project used is 0.9.8e.
Everything was working fine, until the third party made a recent change to their static library. I wasn't able to successfully compile my application when it included this new version of the static library. The old version compiles fine.
I'm not very familiar with these library dependencies and their backwards compatibility. We were told that we must use the version suggested by the third party. I just want to know if that is really the reason. IMO, I guess it should be backwards compatible, shouldn't it?
Any direction with troubleshooting this issue is very much appreciated.
The following is the compilation error that I'm getting:
cc1plus: note: obsolete option -I- used, please use -iquote instead
In file included from /usr/include/openssl/e_os2.h:56,
from /usr/include/openssl/ssl.h:173,
from MyClass.cpp:28:
/usr/include/openssl/opensslconf.h:13:30: error: opensslconf-i386.h: No such file or directory
/usr/include/openssl/bn.h:288: error: expected ';' before '*' token
/usr/include/openssl/bn.h:304: error: 'BN_ULONG' does not name a type
/usr/include/openssl/bn.h:407: error: 'BN_ULONG' was not declared in this scope
/usr/include/openssl/bn.h:450: error: 'BN_ULONG' does not name a type
/usr/include/openssl/bn.h:451: error: 'BN_ULONG' does not name a type
/usr/include/openssl/bn.h:452: error: 'BN_ULONG' has not been declared
/usr/include/openssl/bn.h:453: error: 'BN_ULONG' has not been declared
/usr/include/openssl/bn.h:454: error: 'BN_ULONG' has not been declared
/usr/include/openssl/bn.h:455: error: 'BN_ULONG' has not been declared
/usr/include/openssl/bn.h:456: error: 'BN_ULONG' does not name a type
/usr/include/openssl/bn.h:471: error: 'BN_ULONG' has not been declared
/usr/include/openssl/bn.h:764: error: 'BN_ULONG' does not name a type
/usr/include/openssl/bn.h:765: error: 'BN_ULONG' does not name a type
/usr/include/openssl/bn.h:766: error: variable or field 'bn_sqr_words' declared void
/usr/include/openssl/bn.h:766: error: 'BN_ULONG' was not declared in this scope
/usr/include/openssl/bn.h:766: error: 'rp' was not declared in this scope
/usr/include/openssl/bn.h:766: error: expected primary-expression before 'const'
/usr/include/openssl/bn.h:766: error: expected primary-expression before 'int'
/usr/include/openssl/bn.h:767: error: 'BN_ULONG' does not name a type
/usr/include/openssl/bn.h:768: error: 'BN_ULONG' does not name a type
/usr/include/openssl/bn.h:769: error: 'BN_ULONG' does not name a type
/usr/include/openssl/ssl3.h:303: error: 'PQ_64BIT' does not name a type
/usr/include/openssl/pqueue.h:73: error: 'PQ_64BIT' does not name a type
/usr/include/openssl/pqueue.h:80: error: 'PQ_64BIT' was not declared in this scope
/usr/include/openssl/pqueue.h:80: error: expected primary-expression before 'void'
/usr/include/openssl/pqueue.h:89: error: 'PQ_64BIT' has not been declared
/usr/include/openssl/dtls1.h:92: error: 'PQ_64BIT' does not name a type
/usr/include/openssl/dtls1.h:94: error: 'PQ_64BIT' does not name a type
The error message says that there's no such file as opensslconf-i386.h, but it is indeed present.
Any idea what's going wrong?
Thanks for you time!
The C pre-processor is not finding the opensslconf-i386.h file - so you need to find out why that is failing. You've got a warning from the compiler about using an obsolete option (and it recommends a fix) - do it.
OK - you say the file is present: where is it, and what are the permissions on it? How is it included by opensslconf.h? How is that line different from any other OpenSSL headers that are included. What are the '-I' options you are using other than the deprecated '-I-'?
At this stage, I'd say you've got either a faulty installation or an odd-ball command line.
And the question title is ... not obviously related to the question body.
At the operational level, yes, the two interwork for most purposes.
At the compilation level, yes, the two are basically compatible (that which worked in 0.9.7a should work with 0.9.8e).
At the internals and configuration level, there will be small differences; there may be extra ciphers or modes supported by the more recent version, for example.