Home › Forum › SOFA › Programming with SOFA › add_executable cannot create target, another target with the same namea exist.
Tagged: 64_bits, Linux_ubuntu, SOFA_1706
- This topic has 3 replies, 2 voices, and was last updated 6 years, 6 months ago by Hugo.
-
AuthorPosts
-
3 April 2018 at 11:59 #10748bayminBlocked
Hello.
When I was following the documentation on the Internet and I was doing
the “Programming with SOFA”/”Start coding”, there were something wrong
with my plugins.At first, It was always showing this:
CMake Error at CMakeLists.txt:15 (find_package): By not providing "FindSofaFramework.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "SofaFramework", but CMake did not find one.
Then I dealt it like this:
cmake -DCMAKE_PREFIX_PATH=/home/baymin/sofa/lib/cmake
And it showed that:
CMake Error at CMakeLists.txt:28 (add_executable): add_executable cannot create target "MyPlugin" because another target with the same name already exists. The existing target is a shared library created in source directory "/home/baymin/sofa/src/applications/plugins/MyPlugin". See documentation for policy CMP0002 for more details.
So what should I do to build my plugins?
Thank you very much.
Best,
Baymin
4 April 2018 at 15:14 #10758bayminBlockedHi,
I found my mistake about building my plugins from the tutorial. Build a package in sofa/applications/plugins, and then add “sofa_add_plugin” into the CMakeList.txt in plugins. By using “cmake-gui ../../src” I can select my plugin package, and use “make” to build it.
But there are some new problems:
SofaComponentAdvanced/initComponentAdvanced.h: No such file or directory
Then I copy the “sofa/modules” into “sofa/SofaKernel/modules” and new problems appear:
In function ‘int main(int, char**)’: error: ‘ExecParams’ has not been declared ExecParams::defaultInstance()->setAspectID(0); error: ‘GNode’ is not a member of ‘sofa::simulation::tree’ sofa::simulation::tree::GNode* groot = new sofa::simulation::tree::GNode; ...
I copied the Main.cpp from the docmetation:
So how can I build my own plugins.Thank you very much.
Best,
Baymin
5 April 2018 at 08:03 #10759bayminBlockedHi,
I had put my plugin package into “sofa/applications/projects”, and then add “sofa_add_plugin” into the CMakeList.txt in “sofa/applications/projects”. By using “cmake-gui ../../src” and use “make” to build it.
The problems cannot find “*.h” files had been solved, but there are some new problems again:
In file included from sofa/applications/projects/MyPlugin/Main.cpp:17:0: sofa/SofaKernel/SofaCommon/../modules/SofaSimulationTree/GNode.h: In function ‘int main(int, char**)’: sofa/SofaKernel/SofaCommon/../modules/SofaSimulationTree/GNode.h:48:5: error: ‘sofa::simulation::tree::GNode::GNode(const string&, sofa::simulation::tree::GNode*)’ is protected GNode( const std::string& name="", GNode* parent=NULL ); ^ sofa/applications/projects/MyPlugin/Main.cpp:57:72: error: within this context sofa::simulation::tree::GNode* groot = new sofa::simulation::tree::GNode; ^ sofa/applications/projects/MyPlugin/Main.cpp:60:12: error: ‘class sofa::simulation::tree::GNode’ has no member named ‘setGravityInWorld’ groot->setGravityInWorld(g); ^ sofa/applications/projects/MyPlugin/Main.cpp:72:51: error: request for member ‘get’ in ‘groot’, which is of pointer type ‘sofa::simulation::tree::GNode*’ (maybe you meant to use ‘->’ ?) sofa::simulation::getSimulation()->init(groot.get());
I had use “grep” to find the function setGravityInWorld and could not find the definition of “setGravityInWorld”. So how can I build my own plugins and run them.
Thank you very much.
Best,
Baymin
27 April 2018 at 15:53 #10843HugoKeymasterSorry for the delay of reply @baymin !!
Regarding the online documentation, you can update yourself when you find any issue/incorrect info. The documentation is Markdown files versioned on a Git repo :
https://github.com/sofa-framework/doc
Anyone can contribute (pull-request) !Your main issue is that you try to access a GNode line 17 of your Main.cpp which is protected. You can get inspired of the Main.cpp of the runSofa project in “sofa/applications/projects”“.
I hope this helps.
Best regards,Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.