I have a project on my local computer and I want to run/debug a cppunit Test on a server (Debian). I created the .o files with Netbeans and set the permissions to executable.
drwxr-xr-x 2 myName myGroup 4096 18. Dec 08:40 .
drwxr-xr-x 3 myName myGroup 4096 18. Dec 08:40 ..
-rwxr-xr-x 1 myName myGroup 393488 18. Dec 08:40 SisyTestData.o
-rwxr-xr-x 1 myName myGroup 3127 18. Dec 08:40 SisyTestData.o.d
-rwxr-xr-x 1 myName myGroup 30016 18. Dec 08:40 SisyTestDataRunner.o
-rwxr-xr-x 1 myName myGroup 173 18. Dec 08:40 SisyTestDataRunner.o.d
If I try to run ./SisyTestDataRunner from the directory where it is locate I get
bash: ./SisyTestDataRunner: Datei oder Verzeichnis nicht gefunden
(means: File or Directory not found)
If I try to run ./SisyTestDataRunner.o I get
bash: ./SisyTestDataRunner.o: Kann die Datei nicht ausführen.
(means: Can not execute the file)
SisyTestDataRunner looks like the following:
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
int main() {
// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
// Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener(&result);
// Add a listener that print dots as test run.
CPPUNIT_NS::BriefTestProgressListener progress;
controller.addListener(&progress);
// Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
runner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
runner.run(controller);
// Print test in a compiler compatible format.
CPPUNIT_NS::CompilerOutputter outputter(&result, CPPUNIT_NS::stdCOut());
outputter.write();
return result.wasSuccessful() ? 0 : 1;
}
The file SisyTestData contains one testcase that worked when I started it on my local computer (but it ran on the server).
Is it in general impossible to run a file created by netbeans from command line? Do I have to compile and link it directly on the server?
Ok! go in steps.
For this I think you may link directly their object files in your remote machine in this mode:
$ g++ -o mybin myobj.o
Note that the linker should be able to find all references to the library included in the project!
2) Normally in a standard C++ Project in NetbeansIDE,after you build proyect, you can find the executable file in the folder "dist" example "dist/Debug/GNU-Linux-x86" This file is ready to run on local and remote machines based on linux.
3) It's possible that your executable need some system library. This library in your local machine are correctly referenced, but not in your remote machine
To resolve this problem can help you the command,
$ ldd mybin
You can view the entire process simplified in this screenshot:
Steps of compilation in NetBeans: