'g++-dw2' is not recognized as an internal or external command, - c++

When I try to use gcc 4.6.2 with my qt I'm getting following error:
'g++-dw2' is not recognized as an internal or external command.
In Qt's pro file I have added:
QMAKE_CXXFLAGS += -std=c++0x
QMAKE_CXX = g++-dw2
QMAKE_LINK = g++-dw2
If I don't add those two lines I'm getting error: undefined reference to _unwindSomething
Does anyone knows how to solve it?

To solve the problem at hand:
If g++-dw2 is not already on your system, then you need to install it. Then you need to add it to your path or at least tell Qt the full path to the executable.

Related

How to use libsensors in QT application?

I am trying to make a simple CPU temp program in QT for Linux, but I cannot get libsensors to work with my project. As soon as I include the sensors/sensors.h and try to call int err = sensors_init(NULL); the compiler throws an error undefined reference to 'sensors_init'. I believe this is a linking issue, but I cannot solve it.
Edit:
I can fix the problem if I manually compile outside of QT creator with g++ -o main main.cpp -lsensors.
Now my question is how do I pass the -lsensors parameter to the g++ compiler in the QT creator. I am using qmake.
The solution is to add QMAKE_LIBDIR_FLAGS += -lsensors to the .pro file.

Using grpc with QtCreator, undefined reference to `grpc::...`

I am trying to write some code in C++ in QtCreator to connect to a grpc server when I get this compiler error:
/some/path/serverproxy.cpp:40: error: undefined reference to `grpc::InsecureChannelCredentials()'
Here's my grpc includes at the top of serverproxy.cpp
#include <grpc++/channel.h>
#include <grpc++/create_channel.h>
#include <grpc++/security/credentials.h>
and the error comes from this line:
somenamespace::NewStub(
grpc::CreateChannel("someaddress",
grpc::InsecureChannelCredentials()))};
I tried adding existing files and adding these headers in QtCreator (although it would be very strange to have to do that manually for the headers to all external libraries), but it didn't work. They are located at /usr/local/include/grpc++/**/*.h.
Also tried adding INCLUDEPATH += /usr/local/include to my .pro file.
I also tried cleaning the project, running qmake and building again.
What do I have to do to be able to use these grpc++ functions?
I looked at so many undefined reference in qtcreator threads without noticing this, which I finally saw here which is what got rid of the undefined reference errors:
You are facing a link error. Just add in your .pro the path to your
lib and its name with :
LIBS += -L<path_to_the_lib> -l<libName>
specifically
LIBS += -L/usr/local/include/grpc++ -lgrpc++

Can't link ncurses with Qt

I included <ncurses.h> , but can't link ncurses's libs in .pro file. I'm trying like this:
LIBS += -L"/usr/lib/" -libncurses.a
I tried different variations of linking (with/without file_type, different variations of directory), but it didn't help. Then I decided to link via console using:
g++ -lncurses main.cpp snake.cpp
Tried to put -lncurses in different places of command.
It gives me an error:
undefined reference to move(); (ncurses's func)
And it doesn't want to compile C++11 features, like std::list.empalce_front();. The reason I'm asking for help for second problem in the same question, is that if would able compile only via console, so i won't be able to use C++11 features, but i want to!
P.S. Of course, the main problem is with linking ncurses's libs
http://www.lucidarme.me/?p=3961 Here You can find a solution. Main reason is You incorrectly set project:
LIBS += -lncurses
Check a link I sent You. Everything is there clear.

Errors while trying to compile with external libraries

I have downloaded the mimetic library installation files,
and followed the INSTALL instructions.
./configure
a script that creates the make file after checking a series of things.
make
compiles the cpp files, after this different .o and .lo files appear in the original folder.
make install
seems to do a lot but the only thing that I seem to notice is that a mimetic directory
appears under /usr/local/include with all the header files.
than I try to compile the most simple main file possible:
(as offered in the library site : original example )
#include <mimetic/mimetic.h>
using namespace mimetic;
int main()
{
MimeEntity me;
return 0;
}
I am compiling with following command ( on CentOS 5.7, gcc version : 4.1.2 ):
g++ mimetic.cpp
The error I get:
/tmp/ccWnsteO.o: In function `main':
mimetic.cpp:(.text+0x80): undefined reference to `mimetic::MimeEntity::MimeEntity()'
mimetic.cpp:(.text+0x91): undefined reference to `mimetic::MimeEntity::~MimeEntity()'
collect2: ld returned 1 exit status
From this I understand that the header files are found but the source/library itself
is missing.
the MimeEntity constructor declaration appears in : /usr/local/include/mimetic/mimeentity.h
when I do a search for mimeentity I get the following :
/home/mimetic-0.9.7/mimetic/mimeentity.o
/home/mimetic-0.9.7/mimetic/mimeentity.h
/home/mimetic-0.9.7/mimetic/mimeentitylist.h
/home/mimetic-0.9.7/mimetic/mimeentity.cxx
/home/mimetic-0.9.7/mimetic/.libs/mimeentity.o
/home/mimetic-0.9.7/mimetic/mimeentity.lo
/home/mimetic-0.9.7/mimetic/.deps/mimeentity.Plo
/usr/local/include/mimetic/mimeentity.h
/usr/local/include/mimetic/mimeentitylist.h
I've tried with a search path to the libraries but the same error appears
g++ mimetic.cpp -L/home/mimetic-0.9.7/mimetic/
Something else strange is happening, when I try to compile the main mimetic.cpp file
with the line
MimeEntity me;
changed to
MimeEntity me();
it compiles.
You are getting a linker error simply because you are not referencing the library when compiling the test source file. It needs to be something like:
g++ mimetic.cpp -l<libraryname>
The reason it compiles when you add the braces is that you are really declaring a function called 'me' that returns a MimeEntry. While it compiles, it does not do what you want.
The command you are using to build your mimetic example seems incomplete. You are specifying library search patch (-L) but not the library itself.
Make sure that -L option specified the location of the mimetic library
Add -l'the-name-of-the-mimetic-library'. My guess would be -lmimetic
Add -I (that is capital i) option for the location of the headers.

Trouble using Botan with Qt

I am using Qt and I am trying to use Botan. Everything seemed to go well, but when I go:
Botan::BigInt myInt;
In my constructor it works fine, but on the other hand if I go:
Botan::AutoSeeded_RNG rng;
It throws undefined errors:
C:\Users\Stevie\Desktop\asfsdf-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\debug\mainwindow.o:-1: In function `AutoSeeded_RNG':
C:\Users\Stevie\Desktop\asfsdf-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\..\..\..\..\botan\include\botan\auto_rng.h:40: error: undefined reference to `_imp___ZN5Botan23Global_State_Management12global_stateEv'
C:\Users\Stevie\Desktop\asfsdf-build-desktop-Qt_4_8_1_for_Desktop_-_MinGW__Qt_SDK__Debug\..\..\..\..\botan\include\botan\auto_rng.h:40: error: undefined reference to `_imp___ZN5Botan13Library_State10global_rngEv'
:-1: error: collect2: ld returned 1 exit status
I have no idea why it would work with a BigInt but not the AutoSeeded_RNG, but here are my exact steps:
Compiled the Botan source included in the Qt Creator source at "src/libs/3rdparty/botan/"
I installed Botan using the Windows Installer (1.10) from their website.
I took the libBotan.a, libBotand.a, botan.dll, and Botand.dll and put them in the location where I installed Botan (C:\botan). I overwrote any of those files that already existed.
I then created a new Qt project, and inside of the .pro file I added the following lines:
INCLUDEPATH += "C:/botan/include"
LIBS += "C:/botan/libBotan.a"
Next, I go into my "mainwindow.cpp", and add:
#include <botan/botan.h>
Everything compiles up to here successfully.
I now add this to my constructor:
Botan::AutoSeeded_RNG rng;
Now the above errors are thrown, and cannot be ran. If I replace the "AutoSeeded_RNG" with "BigInt", then it compiles perfectly.
Thanks for any help, Hetelek.
The statement to link against the Botan library looks strange to me. Normally, you specify library directories using the -L switch and add a library with the -l switch, i.e you should use
LIBS += -L"C:\botan" -lBotan
Note that the prefix and suffix of the library are not specified in lbotan. The linker will automatically look for a libbotan.a or botan.dll, depending on your environment.
Botan is also part of QtCreator. Maybe you should have a look at their repository. You can find .pri and .pro files there and probably only need to copy them. They also have written a .qbs driver for the new Qt build system.
Edit: I just compiled Botan from the QtCreator sources, as you also mentioned in your post. I then copied all the generated libraries in my own directory and I also used the botan.h which was shipped with QtCreator. On Linux I had to add
LIBS += -L"/dir/into/which/i/copied/botan/dlls" -LBotan -ldl
to the qmake .pro file. Note the additional -ldl otherwise I got undefined references to dlym, dlerror etc. I could compile a simple example with Botan::AutoSeeded_RNG without problems.