How to enable qt4 code completion in eclipse? - c++

I develop app with some elements of Qt. I use cmake as build system and Eclipse only as editor and debugger. Everything comiles fine (thanks to CMake), however I can't force IDE to complete my Qt code.
Many times someone asked about it and the solution was to add include path. I did it of course, but
#include <QtSql>
is different, because there is no such file in include dir. It probably would work if I include all necassary files by hand. Is there any way to make Eclipse understand that "QtSql" means all classes from this module?

Install qt4 eclipse integration package. You can find instructions here
As the webpage says, the module package should live inside eclipse/plugins, untar the package and start eclipse just one time from the command-line:
eclipse -clean

From your question, I assume that you already have set up other Qt modules like QtCore or QtGui in Eclipse, if not please see this posting: https://stackoverflow.com/a/12670991/1611055
To also use the QSql submodule (without the eclipse Qt Plugin which is, IMHO, not maintained anymore) you need to add the following settings in "Project Properties => C/C++ General => Paths and Symbols":
On the "Includes" tab, for the GNU C++ language, add the following include paths:
/usr/include/qt4/QtSql
On the "Symbols" tab, for the GNU C++ language, add the following symbols with a value of "1":
QT_SQL_LIB
With these settings, the Eclipse C++ indexer also knows the QtSql classes.

Related

Export Eclipse Compiler to cmd

I try to compile an eclipse-project written in c++ which is building a .so-File. Now i try to build the project without an IDE. I tried it with MinGW but the created .so doesn't work. I think there are used some special packages but how can I get the information's.
Is there a way to Export the build settings and import them into MinGW?
How can i else set the compiler?
This is the ToolChainEditor which i would recreat in MinGW.
You can't import a configuration into mingw, but you can tell mingw where to find a configuration of sorts.
Eclipse can be configured to generate a makefile (At least as recent as Neon). Select your project and use the main menu to navigate Project->Properties->C/C++ Build->Tool Chain Editor. Set the "Current builder" to Gnu Make Builder and build the project.
In the generated folder where you would find the finished executable you will find three more files: makefile, objects.mk and sources.mk and can use the make utility that often comes with mingw. It can also be downloaded separately if you have to.
From the command line, enter the folder and type make. Magic will happen. If you want to know more about the magic, make is a very deep topic well worth learning, even if only as a gateway drug to more modern build systems that descended from it.

Import non-cmake GitHub project in CLion

Checking CLion help https://www.jetbrains.com/help/clion/2016.2/importing-existing-non-cmake-project.html I see how to import a non-CMake project into CLion.
And I'm also able to clone a project from GitHub https://www.jetbrains.com/help/clion/2016.2/cloning-a-repository-from-github.html
The project https://github.com/quickfix/quickfix uses ./bootstrap and ./configure to setup a makefile.
What I'd like to do is import that makefile into my CLion project and build and run from that. Is this possible?
While it is possible to "import a project" that's not CMake-based into your CLion project, CLion does not itself directly support using Makefiles as an origination point for a project yet. I know that this is something that has been wanted by many people, and as far as I know, the creators of CLion are at some point planning to integrate some support for this.
In the meantime, however, there is no handy way to do this directly. CMake is a build system configurator, in that it generates its own set of Makefiles to build everything, based on the things you write in your CMakeLists.txt file.
Your best bet, should you want to use the quickfix lib in a project of yours, is to learn the CMake process for building an external dependency, and then linking it to your project. A good blog post on such a thing can be found here. If you simply want to work on changes to it in CLion for your own convenience, but keep the original build files, you could just have CLion generate its own little CMakeLists.txt file for the purposes of importing and color-coding everything, and then set your debug config, etc to point to the binaries generated by running make in the command line.
Long story short, there's no easy way to do what you are talking about directly, but depending on your intended purpose, there are a couple of alternate paths to a similar end. Hope this helps!
Support for Makefiles has been added to CLion, however, the feature is (as of writing) still in early development.
This feature allows for a CLion project to be created by selecting File > Open from the main menu and then selecting the top level Makefile for the project.
More details of the feature can be found here: https://www.jetbrains.com/help/clion/makefiles-support.html

NetBeans with C++ and OpenGL / Freeglut under Windows 7

I recently tried to figure out how to use freeglut with NetBeans 7.
I Google'd a lot and I didn't find a suitable tutorial on how to bind the stuff I need into it.
Currently I have more problem then this:
First one is:
- freeglut 2.8 => in order to compile it I need MinGW and msys.
I have both installed but I can't "configure" or "make all" and "make install" freeglut.
I didn't find an easy-to-read how-to for that task.
Next one:
- once built, where to put what files into a specific folder?
Last one:
- Once put the files into corresponding folder, how to use finally freeglut under NetBeans 7 on a C++ project?
I feel like a lack of information on that.
All I found are always answers like:
download, build, install and done. But I'm already stuck on the "install" and "build".
The solution:
Close NetBeans.
Install and download MinGW from mingw.org
After installing, add the Path to your SystemEnvironemt (example: C:\MinGW).
go to Start->Computer, right mousebutton, select properties
go to advanced system setting, in the following dialog press "Environment Variables".
in the tab "system variables", find the entry Path (or PATH)
add: C:\MinGW;
get freeglut pre-compiled package:
(http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/)
there is a good tutorial how to set up.
Now have fun (just #include " and you're done.
have fun.
Note #1:
if you have problems finding make, the folder is:
C:\MinGW\msys\1.0\bin\make.exe
(when installed MinGW on C:\MinGW).
"mingw-get install msys" in command line should get msys...
last but not least dont forget to add msys\bin to path, too. :)
here's a full tutorial, but in german language.
http://techchan.blog.de/2012/03/18/einrichten-opengl-netbeans-7-1-1-teil-0-start-13209096/
If you need it in english, let me know if you could translate it ;) otherwise i'll think about to translate it myself.
I had a difficult time getting glut working in Netbeans on Windows 7 until I found freeglut, I attributed this to the fact that glut is just very out of date and so are the tutorials I found.
Maybe this will help others looking for instructions on using freeglut in Netbeans. These instructions are like the ones in the link already provided, but help explain how to use it in Netbeans rather than from the command line. This tutorial expects that you've already gotten Netbeans and your compiler working together. IF you have not done so, I found the guide here very helpful: http://netbeans.org/community/releases/68/cpp-setup-instructions.html#mingw
download and extract freeglut from http://www.transmissionzero.co.uk/computing/using-glut-with-mingw/ into an easy to reach folder. (I recommend C:/FrGlut)
either add the bin folder (C:\FrGlut\bin) to your Windows PATH variable, or copy the freeglut.dll from your bin folder into C:\Windows\System32
Open Netbeans and open or create your project
go to: file->project properties
Select your compiler, go to include directories, and add the path to your freeglut include folder (C:\FrGlut\include)
under linker, select add libary, and navigate to the file C:\FrGlut\lib\libfreeglut.a
select options and add the following individually:
-dynamic -lfreeglut -lopengl32 -LC:\FrGlut\lib\libfreeglut.a
Netbeans should now be ready to use with your freeglut library.
To use the glut libary add the following include to your source:
#include <GL/glut.h>
Remember that freeglut.dll will need to be shared along with your executable in order for the program to run, as most users will not already have it.

Cmake support in Eclipse

According to this, I have 3 options to use cmake in Eclipse CDT for C++. None of them works.
The first is because I use out-of-source builds and the limitations of the generator is so lame. Also, it uses a hardcoded Eclipse project template, so it is fragile like hell. The second is the poor man's version of cmake support. It does not add any value to Eclipse, really. The third one simply does not work. I can't make an existing cmake project. I can create a new one, but not opening an existing one. Also, the cmake properties in the project properties windows throw an exception and that's it. Does not even show up.
Is there any GOOD support in Eclipse for cmake? Or any other powerful IDE? Like adding the CmakeList.txt and the corresponding project is created? I am mainly interested in having the proper include paths and the global make targets based on the cmake files. And of course it would be nice to have syntax colored editing of cmake files, etc.
We successfully use both Eclipse CDT and Qt Creator with a large CMake based project.
For Eclipse, we usually use option two exactly as described. There is also a CMake Eclipse plug-in called CMake Editor for syntax highlighting and command completion.
Personally, I am using QtCreator. It has quite good CMake support and is very fast. You should initially configure your project with the CMake GUI (using the Make or NMake Generator) and then open your top-level CMakeLists.txt file in QtCreator and point it to your already configured binary directory.
Have you taken a look at Qt Creator? It might have the features you are looking for.
I use CMake GUI for generating CDT project or Unix makefiles and then import it via Eclipse.
Also I use KDevelop 4 because it simply opens CMake projects and tightly integrates CMake support.
Congratulations, CLion http://www.jetbrains.com/clion/ new C++ IDE with CMake well integrated. See its features https://www.youtube.com/watch?feature=player_embedded&v=MY_Z90Tj6is
I tried all three and have found option 2 to be the only useful one. Option 1, the cmake CDT generator, is useless. I cannot get option 3 to work either.
Yes, option 2 is the "poor man's version" insofar as you must follow a series of steps when setting up a new project, rather than pressing a single button. But I have had good success with it for many projects in the past year. Like you, I always do out of source builds.
Also, to get syntax coloring of CMake files, use the excellent CMakeEd plugin for eclipse. It's beautiful.
CDT has official CMake support plugin currently. You can find through Help->Install menu of Eclipse.

Making a cross platform library with CMake?

Is CMake difficult to use? I've been developing a library using Windows and MSVC++ . I tested my code in Linux and OSX by tediously making objects from each file and making a library out of this.
I have several Directories ex:
Agui
-> Widgets
->Button
->ListBox
-> Backends
-> Allegro
And what I'd like is, for example, if I'm on Windows, it auto generates an msvc project with all these directories and files included and ready to be compiled.
On Linux and OSX I'd like to be able to do something like
cmake
make
is this possible with CMake, and easy to do given my situation.
Thanks
Yes, that is exactly the reason CMake is made for. Huge projects like KDE use CMake.
And its easy to setup.
This is exactly what CMake was developed to do. CMake generates native build files and workspaces that can be used on your platform of choice. So on Unix this is normally Unix Makefiles, on Windows Visual Studio you can select your Visual Studio version to generate a solution that can be opened in the IDE, or use NMake Makefiles.
If you want to add a simple library, you just use the add_library function, giving it a library name and a list of source files. I would recommend taking a look at the CMake tutorial for a brief overview. There is also a book, Mastering CMake, along with many tutorial pages. You can ask the CMake command line for help too, 'cmake --help-command add_library' would show you the add_library documentation.
CMake will generate project files for a number of IDEs, but I find that automake+libtool tend to be easier to use. Here is an excellent tutorial: http://www.lrde.epita.fr/~adl/autotools.html
Don't be put off by the page count: most of it is step-by-step revealing of diagrams.