In my C++ linux project I wanna create daemon executable that forks and executes actual executable. I couldn't find a facility in netbeans IDE to create multiple main files that compile into corresponding executables. Need help in doing it in Netbeans IDE.
1 Answer
Netbeans uses generated makefiles, those don't allow multiple main()-functions. As a solution you can write your own makefile.
However, you can use CMake with NetBeans instead (personal recommendation). CMake allows you to compile several executable / libraries in one run.
Some advantages (respective to your problem):
- Managing and compilation of multiple projects - each separated or all together
- Not limited to Netbeans - CMake can generate project- or makefiles for various IDE's, even commanline-building is possible
- Clean separation of actual code and build stuff
NetBeans supports CMake, so it will build as usual; you just have to write a CMakeLists.txt (~ a makefile) by your own - but thanks to good documentation this wont be a huge problem.
6 Comments
Necktwi
yeah I've seen cmake command specified in C/C++ preferences. Now how to build my project using cmake instead of make? Should I just have to change Makefile to cmake interpretable format?
ollo
No, better create a new project with existing sources. There you select the base directory of your project (= where the main
CMakeLists.txt is) and continue as usual. If all is ok, NB will CMake and build your project.ollo
Btw. a good tip: When creating such a project, select configuration mode = custom, and on the next page select Run configure script in subfolder (
build is the default value there) -- continue with next until finished. This little setting will place all local cmake stuff (= cmake cache) in a folder build and therefore keeps your project dir clean of such files. But as i said before, it's just a tip - using automatic will work fine too.Necktwi
I never used cmake before. I should dig into it. So can't I create new project with cmake as default?
ollo
CMake-based project are handled a bit different. Normal projects create all necessary files (makefiles etc.) for you. If you use CMake, you write a cmake file (
CMakeLists.txt) and tell netbeans to make a project with that. This sounds more complex than it actually is, you'll see :-) Cmake has a great documentation and lots of examples around (btw. if you have your basic skeleton you can use this for almost all projects with minor changes). |