0

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 1

1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

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?
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.
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.
I never used cmake before. I should dig into it. So can't I create new project with cmake as default?
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).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.