Makefile compilation error with 2 or more files

   8276   10   1
User Avatar
Member
10 posts
Joined: 8月 2010
Offline
Hello,

I'm learning to develop a Houdini plugin with C++. I haven't got any problems to compile with hcustom or with a makefile for one cpp file. But, when I try to compile 2 or more cpp files, I have an error of multiple definition on houdini library.

The unique solution I've find for the moment to compile several C++ file is… include cpp file in the main file and just compile this one :?

This is my makefile:

# Installation directory.
INSTDIR = $(HOME)/houdini11.0

# List of C++ source files to build.
SOURCES = \
./src/ParticleEmiter.C \
./src/ParticuleGeometry.C

# Use the highest optimization level.
OPTIMIZER = -g

# Set the plugin library name.
DSONAME = SIM_ParticleEmiter.so

# Include the GNU Makefile.
include $(HFS)/toolkit/makefiles/Makefile.gnu

all: SIM_ParticleEmiter.so


When I compile with this file, I've this error:


g++ -shared ./src/ParticleEmiter.o ./src/ParticleGeometry.o -L/usr/X11R6/lib -lGLU -lGL -lX11 -lXext -lXi -ldl -lpthread -oSIM_ParticleEmiter.so
./src/ParticleGeometry.o: In function `new_allocator':
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/new:94: multiple definition of `HoudiniDSOVersion'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/UT/UT_DSOVersion.h:64: first defined here
./src/ParticleGeometry.o: In function `HoudiniCompilerVersion':
/opt/hfs11.0.446.9/toolkit/include/UT/UT_DSOVersion.h:80: multiple definition of `HoudiniCompilerVersion'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/UT/UT_DSOVersion.h:80: first defined here
./src/ParticleGeometry.o: In function `bool GVEXimportData<UT_Matrix4T<float> >(GB_GenericData const&, UT_Matrix4T<float>&)':
/opt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:275: multiple definition of `bool GVEXimportData<UT_Matrix4T<float> >(GB_GenericData const&, UT_Matrix4T<float>&)'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:275: first defined here
./src/ParticleGeometry.o: In function `bool GVEXimportData<UT_Matrix3T<float> >(GB_GenericData const&, UT_Matrix3T<float>&)':
/opt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:274: multiple definition of `bool GVEXimportData<UT_Matrix3T<float> >(GB_GenericData const&, UT_Matrix3T<float>&)'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:274: first defined here
./src/ParticleGeometry.o: In function `bool GVEXimportData<UT_Vector4T<float> >(GB_GenericData const&, UT_Vector4T<float>&)':
/opt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:273: multiple definition of `bool GVEXimportData<UT_Vector4T<float> >(GB_GenericData const&, UT_Vector4T<float>&)'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:273: first defined here
./src/ParticleGeometry.o: In function `bool GVEXimportData<UT_Vector3T<float> >(GB_GenericData const&, UT_Vector3T<float>&)':
/opt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:272: multiple definition of `bool GVEXimportData<UT_Vector3T<float> >(GB_GenericData const&, UT_Vector3T<float>&)'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:272: first defined here
./src/ParticleGeometry.o: In function `bool GVEXimportData<UT_Vector2T<float> >(GB_GenericData const&, UT_Vector2T<float>&)':
/opt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:271: multiple definition of `bool GVEXimportData<UT_Vector2T<float> >(GB_GenericData const&, UT_Vector2T<float>&)'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:271: first defined here
./src/ParticleGeometry.o: In function `bool GVEXimportData<double>(GB_GenericData const&, double&)':
/opt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:270: multiple definition of `bool GVEXimportData<double>(GB_GenericData const&, double&)'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:270: first defined here
./src/ParticleGeometry.o: In function `bool GVEXimportData<float>(GB_GenericData const&, float&)':
/opt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:269: multiple definition of `bool GVEXimportData<float>(GB_GenericData const&, float&)'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:269: first defined here
./src/ParticleGeometry.o: In function `bool GVEXimportData<int>(GB_GenericData const&, int&)':
/opt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:268: multiple definition of `bool GVEXimportData<int>(GB_GenericData const&, int&)'
./src/ParticleEmiter.oopt/hfs11.0.446.9/toolkit/include/GB/GB_GenericData.h:268: first defined here
collect2: ld returned 1 exit status
make: *** Error 1


My configuration is GNU/Linux Cent OS x64 and I compile with gcc.x86_64 version 4.1.2-48.el5 (i can't update this)

Thank.
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
Try the “Compiling with Makefiles” section here
http://www.sidefx.com/docs/hdk11.0/hdk_intro_compiling.html [sidefx.com]
User Avatar
Member
10 posts
Joined: 8月 2010
Offline
I try, my makefile is inspire of exemple of this page.

After research I think (I'm not sure) my error is cause by my gcc compilator. The version 4.1 don't manage “static inline” instruction. I must use the version 4.4 or more but these version don't in Cent OS' repositories.
User Avatar
Member
10 posts
Joined: 8月 2010
Offline
I have install gcc44-c++, the compilation work but when I want to execute the plugin with houdini:

Compiler incompatibility detected. gcc compiler versions below 4.3 are not compatible with gcc compiler versions 4.3 or above.

…..
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
Did you install the gcc 4.4 version of Houdini?
User Avatar
Member
10 posts
Joined: 8月 2010
Offline
Apparently, no. I've just understand version of gcc depend of houdini version.

For CentOS 5, just gcc 4.1 version houdini is possible.

I test with Ubuntu 10.04 to use gcc4.4 for Houdini but on VMware, the software don't start, I have a fatal error:

Fatal error: Segmentation Fault

I don't know if it's an error to vmware, I'll try on an Ubuntu's partition.
User Avatar
Member
19 posts
Joined: 3月 2010
Offline
make sure you include
#include <UT/UT_DSOVersion.h>
#include <OP/OP_Operator.h>
#include <OP/OP_OperatorTable.h>

only onces in the project. anywhere else will give you a error.
best solution is to have a main file where you define it.

something like.

#include <UT/UT_DSOVersion.h>
#include <OP/OP_Operator.h>
#include <OP/OP_OperatorTable.h>

#include “SOP_CollapseSetup.h”
#include “SOP_CollapseSim.h”
#include “SOP_CollapseTransform.h”

void newSopOperator(OP_OperatorTable *table) {

table->addOperator(new OP_CollapseSetupOperator());
table->addOperator(new OP_CollapseSimOperator());
table->addOperator(new OP_CollapseTransformOperator());

}

means you will need to remove the newSopOperator functions from your files but thats how i got it to work on linux and OSX.
User Avatar
Member
519 posts
Joined:
Offline
or use #if !define statements for each of the header files you load.
User Avatar
Member
10 posts
Joined: 8月 2010
Offline
@larsvdb

We have a similar solution for the moment.

@Pagefan

Headers have #ifndef, #define ;-)

Thank for yours answers
User Avatar
Member
25 posts
Joined: 12月 2005
Offline
Hi,

You should define NEED_SPECIALIZATION_STORAGE when compiling with gcc4.1 for Houdini 11. That fixed the issue for me.

See http://www.sidefx.com/docs/hdk11.0/_g_b___generic_data_8h_source.html [sidefx.com] (line 256)
Frederic Servant / Solid Angle / London
www.solidangle.com
User Avatar
Member
10 posts
Joined: 8月 2010
Offline
Hello kikou,

I try and your solution is good for me. Thank you!
  • Quick Links