Difference between revisions of "HOWTO configure QtCreator with ns-3"
From Nsnam
(Detailed QtCreator help) |
(Fix a typo) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == Basic Configuration == | + | == Introduction == |
− | * | + | * There are two possible approaches: |
+ | ** '''variant 1:''' chaining QtCreator to waf, '''or''' | ||
+ | ** '''variant 2:''' using QtCreator with qmake instead of waf. | ||
+ | * In both cases first open a terminal, cd to the ns-3-dev directory and run "./waf configure --enable-examples" or whatever configuration is to your taste, and "./waf build". | ||
+ | |||
+ | == Variant 1: chaining QtCreator to waf == | ||
+ | === Basic Configuration === | ||
+ | * Run "./waf shell", and then '''in the same terminal''' start QtCreator using "qtcreator" command. | ||
+ | ** Under or ''Tools''->''Options''->''Text Editor'' | ||
*** On ''Completion'' tab under '''Behavior''' enable '''Insert space after function name''' | *** On ''Completion'' tab under '''Behavior''' enable '''Insert space after function name''' | ||
** Under ''Tools''->''Options''->''C++'' | ** Under ''Tools''->''Options''->''C++'' | ||
Line 6: | Line 14: | ||
*** On ''File Naming'' tab set '''Source suffix:''' to "cc" | *** On ''File Naming'' tab set '''Source suffix:''' to "cc" | ||
− | == Importing project == | + | === Importing project === |
− | * | + | * Go to ''File'' menu and select ''New File or Project''. |
* Then go to ''Import Project''->''Import Existing Project'' and click ''Choose...'' button. | * Then go to ''Import Project''->''Import Existing Project'' and click ''Choose...'' button. | ||
* '''Project Name and Location''' | * '''Project Name and Location''' | ||
Line 18: | Line 26: | ||
** Click ''Finish'' | ** Click ''Finish'' | ||
− | == Configuring project == | + | === Configuring project === |
* Click '''Edit''' on the left; open "qtcreator-project-ns-3-dev.includes" file. | * Click '''Edit''' on the left; open "qtcreator-project-ns-3-dev.includes" file. | ||
** Edit the line "<path-to-ns-3-dev>/build/ns3" to be "<path-to-ns-3-dev>/build" | ** Edit the line "<path-to-ns-3-dev>/build/ns3" to be "<path-to-ns-3-dev>/build" | ||
* Click '''Projects''' on the left. | * Click '''Projects''' on the left. | ||
** Under '''Build Settings''' | ** Under '''Build Settings''' | ||
− | *** Remove '' | + | *** Remove ''make all'' under '''Build Steps''', and click ''Add Build Step''->''Custom Process Step'' |
**** '''Command:'' should be "./waf" | **** '''Command:'' should be "./waf" | ||
**** '''Working directory:''' is OK by default | **** '''Working directory:''' is OK by default | ||
**** '''Command arguments:''' should be "build" | **** '''Command arguments:''' should be "build" | ||
− | *** Remove '' | + | *** Remove ''make clean'' under '''Clean Steps''', and click ''Add Clean Step''->''Custom Process Step'' |
**** '''Command:'' should be "./waf" | **** '''Command:'' should be "./waf" | ||
**** '''Working directory:''' is OK by default | **** '''Working directory:''' is OK by default | ||
**** '''Command arguments:''' should be "clean" | **** '''Command arguments:''' should be "clean" | ||
** Under '''Run Settings''' | ** Under '''Run Settings''' | ||
− | *** Set '''Executable:''' to "./waf" | + | *** Set '''Executable:''' to "./build/examples/tutorial/ns3-dev-first-debug" or any executable you want to run and debug |
− | *** | + | **** If you set it to "./build/examples/tutorial/ns3-dev-first-debug" make sure you used "--enable-examples" option in "./waf configure" prior to running the code |
− | *** | + | *** Leave '''Arguments:''' blank |
+ | *** '''Working directory:''' is again OK by default | ||
+ | |||
+ | === FAQ === | ||
+ | * Q: I get an error "./build/examples/tutorial/ns3-dev-first-debug: error while loading shared libraries: libns3-dev-point-to-point-debug.so: cannot open shared object file: No such file or directory". | ||
+ | ** A: Please make sure that you are running "qtcreator" inside "./waf shell". | ||
+ | |||
+ | == Variant 2: using QtCreator with qmake instead of waf == | ||
+ | === Configuration and Building === | ||
+ | * Go to ''File'' menu and select ''New File or Project''. | ||
+ | * Then go to ''Non-Qt Project''->''Plain C++ Project'' and click ''Choose...'' button. | ||
+ | * On '''Introduction and Project Location''' choose whatever name you want and clik ''Next >''. | ||
+ | * On '''Project Management''' click ''Next >''. | ||
+ | * On '''Target Setup''' click ''Next >''. | ||
+ | * Right-click on the ''Sources'' folder and select ''Add Existing Files...''. Use it to add all required models and helpers. | ||
+ | * Replace the contents of "main.cpp" with your example file. | ||
+ | * Open the "<project-name>.pro" file and add | ||
+ | INCLUDEPATH += <path-to-ns-3-dev>/build | ||
+ | * Click ''Build'' (this uses qmake and make, rather than waf). | ||
+ | |||
+ | === Debugging === | ||
+ | * Set breakpoints and click Debug. | ||
− | == | + | === Notes === |
− | * '''Start Debugging''' | + | * To debug a running ns-3 program, use ''Debug''->''Start Debugging''->''Attach to Running Local Application''. |
+ | * To start and run a "waf" built ns-3 application, first set click ''Projects'' on the left and then under ''Targets'' and ''Desktop'' select ''Run''. Under '''Run Configuration''', set '''Executable:''' to "<path-to-ns-3-dev>/build/examples/tutorial/ns3-dev-first-debug" and use ''Debug''->''Start Debugging''->''Start Debugging''. |
Latest revision as of 13:04, 2 January 2013
Contents
Introduction
- There are two possible approaches:
- variant 1: chaining QtCreator to waf, or
- variant 2: using QtCreator with qmake instead of waf.
- In both cases first open a terminal, cd to the ns-3-dev directory and run "./waf configure --enable-examples" or whatever configuration is to your taste, and "./waf build".
Variant 1: chaining QtCreator to waf
Basic Configuration
- Run "./waf shell", and then in the same terminal start QtCreator using "qtcreator" command.
- Under or Tools->Options->Text Editor
- On Completion tab under Behavior enable Insert space after function name
- Under Tools->Options->C++
- On Code Style tab set Current setting: to "GNU [built-in]"
- On File Naming tab set Source suffix: to "cc"
- Under or Tools->Options->Text Editor
Importing project
- Go to File menu and select New File or Project.
- Then go to Import Project->Import Existing Project and click Choose... button.
- Project Name and Location
- "Project name:" should be something like "qtcreator-project-ns-3-dev", because QtCreator will create couple of files in ns-3-dev directory and you want to be able to delete them easily if needed.
- "Location:" should be your ns-3-dev directory.
- Click Next >
- File Selection
- Click Next >
- Project Management
- Click Finish
Configuring project
- Click Edit on the left; open "qtcreator-project-ns-3-dev.includes" file.
- Edit the line "<path-to-ns-3-dev>/build/ns3" to be "<path-to-ns-3-dev>/build"
- Click Projects on the left.
- Under Build Settings
- Remove make all under Build Steps, and click Add Build Step->Custom Process Step
- 'Command: should be "./waf"
- Working directory: is OK by default
- Command arguments: should be "build"
- Remove make clean under Clean Steps, and click Add Clean Step->Custom Process Step
- 'Command: should be "./waf"
- Working directory: is OK by default
- Command arguments: should be "clean"
- Remove make all under Build Steps, and click Add Build Step->Custom Process Step
- Under Run Settings
- Set Executable: to "./build/examples/tutorial/ns3-dev-first-debug" or any executable you want to run and debug
- If you set it to "./build/examples/tutorial/ns3-dev-first-debug" make sure you used "--enable-examples" option in "./waf configure" prior to running the code
- Leave Arguments: blank
- Working directory: is again OK by default
- Set Executable: to "./build/examples/tutorial/ns3-dev-first-debug" or any executable you want to run and debug
- Under Build Settings
FAQ
- Q: I get an error "./build/examples/tutorial/ns3-dev-first-debug: error while loading shared libraries: libns3-dev-point-to-point-debug.so: cannot open shared object file: No such file or directory".
- A: Please make sure that you are running "qtcreator" inside "./waf shell".
Variant 2: using QtCreator with qmake instead of waf
Configuration and Building
- Go to File menu and select New File or Project.
- Then go to Non-Qt Project->Plain C++ Project and click Choose... button.
- On Introduction and Project Location choose whatever name you want and clik Next >.
- On Project Management click Next >.
- On Target Setup click Next >.
- Right-click on the Sources folder and select Add Existing Files.... Use it to add all required models and helpers.
- Replace the contents of "main.cpp" with your example file.
- Open the "<project-name>.pro" file and add
INCLUDEPATH += <path-to-ns-3-dev>/build
- Click Build (this uses qmake and make, rather than waf).
Debugging
- Set breakpoints and click Debug.
Notes
- To debug a running ns-3 program, use Debug->Start Debugging->Attach to Running Local Application.
- To start and run a "waf" built ns-3 application, first set click Projects on the left and then under Targets and Desktop select Run. Under Run Configuration, set Executable: to "<path-to-ns-3-dev>/build/examples/tutorial/ns3-dev-first-debug" and use Debug->Start Debugging->Start Debugging.