C++ SSE3 instruction set not enabled - c++

I'm trying to work up some hidden markov code in c++ using the HMMlib library from
http://www.cs.au.dk/~asand/?page_id=152
I am using an ubuntu 12.04, with gcc / g++ 4.6
My compile step instruction is:
g++ -I/usr/local/boost_1_52_0 -I../ MAIN.cpp
This produces the following error:
In file included from ../HMMlib/allocator_traits.hpp:25:0,
from ../HMMlib/hmm_table.hpp:25,
from MAIN.cpp:1:
/usr/lib/gcc/i686-linux-gnu/4.6/include/pmmintrin.h:32:3: error: #error "SSE3 instruction set not enabled"
In file included from ../HMMlib/hmm_table.hpp:25:0,
from MAIN.cpp:1:
../HMMlib/allocator_traits.hpp:50:33: error: ‘__m128d’ was not declared in this scope
../HMMlib/allocator_traits.hpp:50:40: error: template argument 2 is invalid
../HMMlib/allocator_traits.hpp:77:32: error: ‘__m128’ was not declared in this scope
../HMMlib/allocator_traits.hpp:77:38: error: template argument 2 is invalid
In file included from ../HMMlib/hmm_table.hpp:26:0,
from MAIN.cpp:1:
../HMMlib/operator_traits.hpp:112:32: error: ‘__m128d’ was not declared in this scope
../HMMlib/operator_traits.hpp:112:39: error: template argument 2 is invalid
../HMMlib/operator_traits.hpp:205:31: error: ‘__m128’ was not declared in this scope
../HMMlib/operator_traits.hpp:205:37: error: template argument 2 is invalid
In file included from ../HMMlib/hmm_table.hpp:27:0,
from MAIN.cpp:1:
../HMMlib/float_traits.hpp:37:13: error: ‘__m128’ does not name a type
../HMMlib/float_traits.hpp:43:13: error: ‘__m128d’ does not name a type
In file included from ../HMMlib/hmm.hpp:34:0,
from MAIN.cpp:3:
../HMMlib/sse_operator_traits.hpp:63:35: error: ‘__m128’ was not declared in this scope
../HMMlib/sse_operator_traits.hpp:63:41: error: template argument 2 is invalid
../HMMlib/sse_operator_traits.hpp:95:36: error: ‘__m128d’ was not declared in this scope
../HMMlib/sse_operator_traits.hpp:95:43: error: template argument 2 is invalid
I have absolutely no idea what these errors mean, and how to resolve them

You have to enable the sse3 intrinsics of gcc with a command line option. Try compiling with
g++ -msse3 -I/usr/local/boost_1_52_0 -I../ MAIN.cpp
or selecting instruction set by processor
g++ -march=core2 -I/usr/local/boost_1_52_0 -I../ MAIN.cpp
Reply to your comment: -march=native selects the instruction set of the processor you are currently running.
Note that -msse3 already selects its subsets -msse2 and -msse

Related

OpenGL errors finding certain libraries

I am learning about OpenGL and am having great difficulty opening a file with openGL. This is what my reference says to do:
"Compile and run the program
To compile the sample program, you need to link to the OpenGL and freeglut libraries. You will also need the GLEW library to be able to use many OpenGL functions, including shaders.
The exact names of these libraries vary from system to system, for example:
Linux
: libGL.a, libglut.a
Compile with
g++ main.cpp -lGL -lglut -lGLE"
I have run this code in my linux terminal (I'm using Redhat) and I get a whole bunch of errors about not being able to locate the files
[a1649446#ingb24w027 code]$ g++ main.cpp -lGL -lglut -lGLEW
main.cpp:46:23: error: glm/glm.hpp: No such file or directory
main.cpp:47:40: error: glm/gtc/matrix_transform.hpp: No such file or directory
main.cpp:48:32: error: glm/gtc/type_ptr.hpp: No such file or directory
main.cpp:62: error: ‘glm’ has not been declared
main.cpp:62: error: expected constructor, destructor, or type conversion before ‘cameraMatrix’
main.cpp: In function ‘int setShaderData(const unsigned int&)’:
main.cpp:102: error: ‘glm’ has not been declared
main.cpp:102: error: expected ‘;’ before ‘projection’
main.cpp:105: error: ‘glm’ has not been declared
main.cpp:105: error: ‘projection’ was not declared in this scope
main.cpp:109: error: ‘glm’ has not been declared
main.cpp:109: error: expected ‘;’ before ‘modelview’
main.cpp: In function ‘void render()’:
main.cpp:187: error: ‘cameraMatrix’ was not declared in this scope
main.cpp:187: error: ‘glm’ has not been declared
main.cpp:200: error: ‘glm’ has not been declared
I'm sure the answer is painfully obvious, but I am an OpenGL noob. I have even located all the openGL libraries and copy-pasted them into the folder with my main.cpp and all associated files, to no avail.

Building llvm examples

I followed the below from http://llvm.org/docs/GettingStarted.html - which completed successfully:
cd where-you-want-llvm-to-live
get the code
...
make
I put these in my home directory, so my structure looks like
~/llvmHome/llvm/<souce code is here>
~/llvmHome/build/Debug+Asserts/bin/<clang++ executables etc are here>
I'm attempting to follow the steps on http://llvm.org/docs/tutorial/LangImpl3.html to build the example.
I'm performing
cd ~/llvmHom/llvm/examples/Kaleidoscope/Chapter3 //so I'm where I checked out the source code
Then, I'm trying:
~/llvmHome/build/Debug+Asserts/bin/clang++ -g -O3 toy.cpp `~/llvmHome/build/Debug+Asserts/bin/llvm-config --cppflags --ldflags --libs core` -o toy
This gives warnings, and up to the first error
In file included from toy.cpp:1:
In file included from ~/llvmHome/llvm/include/llvm/IR/Verifier.h:24:
In file included from ~/llvmHome/llvm/include/llvm/ADT/StringRef.h:14:
~/llvmHome/llvm/include/llvm/Support/Allocator.h:82:42: warning: 'override' keyword is a C++11 extension [-Wc++11-extensions]
virtual MemSlab *Allocate(size_t Size) override;
^
~/llvmHome/llvm/include/llvm/Support/Allocator.h:83:42: warning: 'override' keyword is a C++11 extension [-Wc++11-extensions]
virtual void Deallocate(MemSlab *Slab) override;
^
In file included from toy.cpp:2:
In file included from ~/llvmHome/llvm/include/llvm/IR/DerivedTypes.h:21:
In file included from ~/llvmHome/llvm/include/llvm/IR/Type.h:19:
In file included from ~/llvmHome/llvm/include/llvm/ADT/APFloat.h:20:
In file included from ~/llvmHome/llvm/include/llvm/ADT/APInt.h:19:
In file included from ~/llvmHome/llvm/include/llvm/ADT/ArrayRef.h:14:
~/llvmHome/llvm/include/llvm/ADT/SmallVector.h:235:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
void push_back(T &&Elt) {
^
~/llvmHome/llvm/include/llvm/ADT/SmallVector.h:187:15: error: no member named 'move' in namespace 'std'; did you mean simply 'move'?
*Dest = ::std::move(*I);
^~~~~~~~~~~
move
Some examaples suggest using g++ to compile, trying that gives
g++ -g -O3 toy.cpp `~/llvmHome/build/Debug+Asserts/bin/llvm-config --cppflags --ldflags --libs core` -o toy
In file included from ~/llvmHome/llvm/include/llvm/ADT/StringRef.h:14:0,
from ~/llvmHome/llvm/include/llvm/IR/Verifier.h:24,
from toy.cpp:1:
~/llvmHome/llvm/include/llvm/Support/Allocator.h:82:40: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 [enabled by default]
~/llvmHome/llvm/include/llvm/Support/Allocator.h:83:40: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11 [enabled by default]
In file included from ~/llvmHome/llvm/include/llvm/ADT/ArrayRef.h:14:0,
from ~/llvmHome/llvm/include/llvm/ADT/APInt.h:19,
from ~/llvmHome/llvm/include/llvm/ADT/APFloat.h:20,
from ~/llvmHome/llvm/include/llvm/IR/Type.h:19,
from ~/llvmHome/llvm/include/llvm/IR/DerivedTypes.h:21,
from toy.cpp:2:
~/llvmHome/llvm/include/llvm/ADT/SmallVector.h:235:20: error: expected ‘,’ or ‘...’ before ‘&&’ token
I'm not sure how how to debug this further, any ideas on what I'm getting incorrect?
Should I be linking to libraries under ~/llvmHome/build/ instead of into the source code?
LLVM (and clang) recently switched to C++ 11. So, you need to have reasonable compiler (e.g. clang or gcc 4.7+) and compile everything with -std=c++11 flag.

Does not name a type_in make prossess

I've been trying to compile some codes in windows but I got this error: 'flann_index_t' does not name a type'
where is this error come from?
Can any one help me to fix this?
g++ -I. -Iflann/src/cpp -c -o src/main.o src/main.cpp
In file included from ./boost/asio/async_result.hpp:18,
from ./boost/asio.hpp:20,
from src/common.hpp:30,
from src/main.cpp:9:
./boost/asio/detail/config.hpp:367:5: warning: #warning Please define _WIN32_WIN
NT or _WIN32_WINDOWS appropriately.
./boost/asio/detail/config.hpp:368:5: warning: #warning For example, add -D_WIN3
2_WINNT=0x0501 to the compiler command line.
./boost/asio/detail/config.hpp:369:5: warning: #warning Assuming _WIN32_WINNT=0x
0501 (i.e. Windows XP target).
In file included from src/common.hpp:50,
from src/main.cpp:9:
src/CBIR.hpp:32: error: 'flann_index_t' does not name a type
./flann/util/matrix.h: In function 'int cbir::main(int, char**)':
./flann/util/matrix.h:75: error: 'flann::uchar* flann::Matrix_::data' is protected
src/main.cpp:39: error: within this context Makefile:43: recipe for target `src/main.o' failed
make: *** [src/main.o] Error 1
Assuming you are using flann, then you need:
#include <flann.h>
in CBIR.hpp.

Errors compiling wxWidgets

I am trying to run the sample code shown here. I built wxWidgets from source using MinGW, with this command: mingw32-make -f makefile.gcc SHARED=1 UNICODE=0 BUILD=debug. In my Eclipse settings, I add -Iwx288/include, -Lwx288/lib, -lwxbase28d_gcc_custom and -lwxmsw28d_core_gcc_custom. I get very very confused, due to the number of ways to compile and inexperience with linkers. I get these errors, what am I doing wrong? I'm not even citing wxMutex in my program.
23:15:19 **** Incremental Build of configuration Debug for project A ****
Info: Internal Builder is used for build
g++ "-IC:\\Files\\Programming\\C++\\A\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "include\\wx\\thrimpl.o" "..\\include\\wx\\thrimpl.cpp"
..\include\wx\thrimpl.cpp:18:1: error: 'wxMutex' does not name a type
..\include\wx\thrimpl.cpp:29:1: error: 'wxMutex' does not name a type
..\include\wx\thrimpl.cpp:34:6: error: 'wxMutex' has not been declared
..\include\wx\thrimpl.cpp:34:22: error: non-member function 'bool IsOk()' cannot have cv-qualifier
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:36:12: error: 'm_internal' was not declared in this scope
..\include\wx\thrimpl.cpp:36:26: error: 'NULL' was not declared in this scope
..\include\wx\thrimpl.cpp: At global scope:
..\include\wx\thrimpl.cpp:39:1: error: 'wxMutexError' does not name a type
..\include\wx\thrimpl.cpp:47:1: error: 'wxMutexError' does not name a type
..\include\wx\thrimpl.cpp:55:1: error: 'wxMutexError' does not name a type
..\include\wx\thrimpl.cpp:224:1: error: 'wxCondition' does not name a type
..\include\wx\thrimpl.cpp:235:1: error: 'wxCondition' does not name a type
..\include\wx\thrimpl.cpp:240:6: error: 'wxCondition' has not been declared
..\include\wx\thrimpl.cpp:240:26: error: non-member function 'bool IsOk()' cannot have cv-qualifier
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:240:6: error: redefinition of 'bool IsOk()'
..\include\wx\thrimpl.cpp:34:6: error: 'bool IsOk()' previously defined here
..\include\wx\thrimpl.cpp:242:12: error: 'm_internal' was not declared in this scope
..\include\wx\thrimpl.cpp:242:26: error: 'NULL' was not declared in this scope
..\include\wx\thrimpl.cpp: At global scope:
..\include\wx\thrimpl.cpp:245:1: error: 'wxCondError' does not name a type
..\include\wx\thrimpl.cpp:253:1: error: 'wxCondError' does not name a type
..\include\wx\thrimpl.cpp:261:1: error: 'wxCondError' does not name a type
..\include\wx\thrimpl.cpp:269:1: error: 'wxCondError' does not name a type
..\include\wx\thrimpl.cpp:281:1: error: 'wxSemaphore' does not name a type
..\include\wx\thrimpl.cpp:291:1: error: 'wxSemaphore' does not name a type
..\include\wx\thrimpl.cpp:296:6: error: 'wxSemaphore' has not been declared
..\include\wx\thrimpl.cpp:296:26: error: non-member function 'bool IsOk()' cannot have cv-qualifier
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:296:6: error: redefinition of 'bool IsOk()'
..\include\wx\thrimpl.cpp:34:6: error: 'bool IsOk()' previously defined here
..\include\wx\thrimpl.cpp:298:12: error: 'm_internal' was not declared in this scope
..\include\wx\thrimpl.cpp:298:26: error: 'NULL' was not declared in this scope
..\include\wx\thrimpl.cpp: At global scope:
..\include\wx\thrimpl.cpp:301:1: error: 'wxSemaError' does not name a type
..\include\wx\thrimpl.cpp:309:1: error: 'wxSemaError' does not name a type
..\include\wx\thrimpl.cpp:317:1: error: 'wxSemaError' does not name a type
..\include\wx\thrimpl.cpp:325:1: error: 'wxSemaError' does not name a type
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:299:1: warning: control reaches end of non-void function [-Wreturn-type]
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:243:1: warning: control reaches end of non-void function [-Wreturn-type]
..\include\wx\thrimpl.cpp: In function 'bool IsOk()':
..\include\wx\thrimpl.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
23:15:20 Build Finished (took 657ms)
Why are you trying to compile include/wx/thrimpl.cpp? It's not your file, it's part of wxWidgets and it shouldn't be compiled as part of your project. Just remove it from the list of project files.
I'm guessing you are either missing something in your include path or some of the Defines required by wxWidgets in order to process wxWidgets Header-Files correctly
WX comes with a tool called wx-config ( should be located somewhere in wxWidgets/bin if your build was successful)
wx-config is a shell-script, you can execute it using mingw-msys
wx-config --cxxflags produces all Include Paths and Defines needed to compile object files.
wx-config --libs takes care of everything needed to link the program
I would recommend using wx-config in your makefile/builder/....
or check the output produced by it and compare it to your build process
Samples form my current installation:
$ wx-config --cxxflags --static=no --debug=yes --unicode=no -I/wx/lib/wx/include/msw-ansi-debug-2.8 -I/wx/include/wx-2.8 -D_WXDEBUG_ -DWXUSINGDLL -D_WXMSW_ -mthreads
$ ./wx-config --libs --static=no --debug=yes --unicode=no -L/wx/lib -mthreads -Wl,--subsystem,windows -mwindows -lwx_mswd_richtext-2.8 -lwx_mswd_aui-2.8 -lwx_mswd_xrc-2.8 -lwx_mswd_qa-2.8 -lwx_mswd_html-2.8 -lwx_mswd_adv-2.8 -lwx_mswd_core-2.8 -lwx_based_xml-2.8 -lwx_based_net-2.8 -lwx_based-2.8

C++ Compilation error against GNU's Multi-precision library

I get the following error when compiling this third-party library (called azove 2.0) which relies on the GNU Multi-precision library:
> make
g++ -Wall -O3 -DFIX_NUMBER_OF_SIGMDDNODE_SONS -DUSE_TIMER -I. -c conBDD.cpp -o conBDD.o
In file included from conBDDnode.hpp:27,
from conBDD.hpp:25,
from conBDD.cpp:22:
/usr/include/gmpxx.h: In destructor ‘__gmp_alloc_cstring::~__gmp_alloc_cstring()’:
/usr/include/gmpxx.h:2096: error: ‘strlen’ was not declared in this scope
conBDD.cpp: In member function ‘void conBDD::build()’:
conBDD.cpp:61: error: ‘numeric_limits’ was not declared in this scope
conBDD.cpp:61: error: expected primary-expression before ‘int’
conBDD.cpp:61: error: expected `;' before ‘int’
conBDD.cpp:68: error: expected primary-expression before ‘int’
conBDD.cpp:68: error: expected `;' before ‘int’
make: *** [conBDD.o] Error 1
I have tried adding either and both of the following lines
#include <cstdlib>
using std::strlen;
to conBDD.cpp, but the error persists.
I can't tell if this is an error comes from GNU's Multi-precision library or from Azove. Any pointers would be greatly appreciated.
I would start by apportioning blame. Create an empty cpp file, say test.cpp, in your project and include only the offending gmpxx.h file. If you can compile test cpp, GMP is off the hook. Then try including only the offending azove header. If you can compile the azove header in an otherwise empty file, azove is off the hook and something you are including/defining is interfering with them. Once you have narrowed down the source of the problem you should find it easier to fix.