Build Programm with Rose Library

Hello,

I am trying to compile a program in NSight, using the Library of the rose compiler(rosecompiler.org)

I can compile such a program without any problems with a manually written Makefile and with standard g++. This one looks like this:

CXX=g++-4.4
CXXFLAGS=-c -Wall

# Anmerkung: BOOST_INSTALL_DIR und ROSE_INSTALL_DIR
# musst du an deine Verzeichnisstruktur anpassen.
# JAVA_HOME ist bei mir eine Umgebungsvariable, die
# ich in der .bashrc setze. Es muss übrigens das
# Oracle Java sein, OpenJDK geht meines wissens nicht.
BOOSTLIBDIR=$(BOOST_INSTALL_DIR)/lib
ROSELIBDIR=$(ROSE_INSTALL_DIR)/lib
JAVALIBDIR=$(JAVA_HOME)/jre/lib/amd64/server
INCLUDE=-I$(ROSE_INSTALL_DIR)/include -I$(BOOST_INSTALL_DIR)/include 
LDFLAGS=-Wl,-rpath-link $(BOOSTLIBDIR) -Wl,-rpath-link $(JAVALIBDIR) -L$(ROSELIBDIR)
#LDFLAGS=-L$(BOOSTLIBDIR) -L$(JAVALIBDIR) -L$(ROSELIBDIR)
LIBS=-lrose -lhpdf


# .cpp-Dateien, die ich sowohl für das Programm als auch für die Testmak
PROJECTSOURCES= 
SOURCEDIR=../src
# .cpp-Dateien, die nur für das Programm benötigt werden
SOURCES=$(PROJECTSOURCES) $(SOURCEDIR)/useRose.cpp
# .cpp-Dateien, die nur für die Tests benötigt werden
TESTSOURCES=$(PROJECTSOURCES) RunAllTests.cpp

OBJDIR=src
OBJECTS=$(SOURCES:%.cpp=$(OBJDIR)/%.o)
TESTOBJECTS=$(TESTSOURCES:%.cpp=$(OBJDIR)/%.o)
# Name der ausführbaren Datei, die es am Ende werden soll
EXECUTABLE=$(OBJDIR)/useRose
ECHO=@echo

# Verzeichnisse, die nach den angegebenen Quelldateien durchsucht werden.
# Ist einfacher, als jeder Datei den Verzeichnispfad voranzustellen, die
# in Unterverzeichnissen sitzen.
vpath %.cpp src src/common test test/util

all: $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
	$(CXX) $(LDFLAGS) $^ -o $@ $(LIBS)

$(OBJDIR)/%.o: %.cpp
	$(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@

test: $(OBJDIR)/runAllTests

$(OBJDIR)/runAllTests: $(TESTOBJECTS)
	$(CXX) $(LDFLAGS) $^ -o $@ $(LIBS)

.PHONY: clean
clean: 
	rm -r $(OBJDIR)/*

How can I set the project properties in NSight in order to use an automatic genereted makefile with nvcc as compiler?

My project properties in Build -> Settings -> Tool Settings are:

NVCC Compiler -> Includes -> Include paths(-I):
/homes/knoppik/tools/install/rose/include
/homes/knoppik/tools/install/boost/include

NVCC Linker -> Libraries -> Libraries(-l):
rose
hpdf

NVCC Linker -> Libraries -> Library search paths(-l):
/homes/knoppik/tools/install/boost/lib
/homes/knoppik/tools/install/jdk1.7.0_09/jre/lib/amd64/server
/homes/knoppik/tools/install/rose/lib

NVCC Linker -> Miscellaneous ->> Other options(-Xlinker [option])
-rpath

The rest are the standard settings. So the settings in NSight Project Properties are nearly the same compared to the ones in the original, manually written Makefile posted above. But after compiling the project I get this (error) output:

**** Build of configuration Debug for project cpso2cuda ****

make all 
Building file: ../src/useRose.cpp
Invoking: NVCC Compiler
nvcc -I/homes/knoppik/tools/install/rose/include -I/homes/knoppik/tools/install/boost/include -G -g -O0  -odir "src" -M -o "src/useRose.d" "../src/useRose.cpp"
nvcc -I/homes/knoppik/tools/install/rose/include -I/homes/knoppik/tools/install/boost/include -G -g -O0 --compile  -x c++ -o  "src/useRose.o" "../src/useRose.cpp"
Finished building: ../src/useRose.cpp
 
Building target: cpso2cuda
Invoking: NVCC Linker
nvcc -L/homes/knoppik/tools/install/boost/lib -L/homes/knoppik/tools/install/jdk1.7.0_09/jre/lib/amd64/server -L/homes/knoppik/tools/install/rose/lib -Xlinker -rpath -link -o  "cpso2cuda"  ./src/useRose.o   -lrose -lhpdf
./src/useRose.o: In function `visitorTraversal::visit(SgNode*)':
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:64: undefined reference to `isSgClassDeclaration(SgNode*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:67: undefined reference to `AstDOTGeneration::generate(SgNode*, std::basic_string, DOTGeneration::traversalType, std::basic_string)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:71: undefined reference to `isSgFunctionDeclaration(SgNode*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:75: undefined reference to `isSgCudaKernelCallExp(SgNode*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:78: undefined reference to `AstDOTGeneration::generate(SgNode*, std::basic_string, DOTGeneration::traversalType, std::basic_string)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:115: undefined reference to `isSgFunctionDeclaration(SgNode*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:124: undefined reference to `SgFunctionDeclaration::get_name() const'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:124: undefined reference to `SgName::str() const'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:124: undefined reference to `SgName::~SgName()'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:126: undefined reference to `SgFunctionDeclaration::get_functionModifier()'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:126: undefined reference to `SgFunctionModifier::isCudaHost() const'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:128: undefined reference to `SgFunctionDeclaration::get_functionModifier()'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:128: undefined reference to `SgFunctionModifier::isCudaDevice() const'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:130: undefined reference to `SgFunctionDeclaration::get_functionModifier()'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:130: undefined reference to `SgFunctionModifier::isCudaKernel() const'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:136: undefined reference to `isSgInitializedName(SgNode*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:139: undefined reference to `SgInitializedName::get_name() const'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:139: undefined reference to `SgName::str() const'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:139: undefined reference to `SgName::~SgName()'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:140: undefined reference to `SgInitializedName::get_type() const'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:146: undefined reference to `isSgForStatement(SgNode*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:149: undefined reference to `Sg_File_Info::generateDefaultFileInfoForTransformationNode()'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:151: undefined reference to `SgPragma::operator new(unsigned long)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:151: undefined reference to `SgPragma::SgPragma(std::basic_string, Sg_File_Info*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:152: undefined reference to `SgPragmaDeclaration::operator new(unsigned long)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:152: undefined reference to `SgPragmaDeclaration::SgPragmaDeclaration(Sg_File_Info*, SgPragma*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:124: undefined reference to `SgName::~SgName()'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:139: undefined reference to `SgName::~SgName()'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:151: undefined reference to `SgPragma::operator delete(void*)'
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:152: undefined reference to `SgPragmaDeclaration::operator delete(void*)'
./src/useRose.o: In function `visitorTraversal::atTraversalEnd()':
/homes/knoppik/Masterarbeit/quellen/cpso2cuda/Debug/../src/useRose.cpp:166: undefined reference to `SageInterface::insertStatement(SgStatement*, SgStatement*, bool, bool)'
./src/useRose.o: In function `AstSimpleProcessing':
/homes/knoppik/tools/install/rose/include/AstSimpleProcessing.h:59: undefined reference to `vtable for AstSimpleProcessing'
./src/useRose.o: In function `~AstSimpleProcessing':
/homes/knoppik/tools/install/rose/include/AstSimpleProcessing.h:59: undefined reference to `vtable for AstSimpleProcessing'
./src/useRose.o: In function `AstDOTGeneration':
/homes/knoppik/tools/install/rose/include/AstDOTGeneration.h:12: undefined reference to `vtable for AstDOTGeneration'
./src/useRose.o: In function `~AstDOTGeneration':
/homes/knoppik/tools/install/rose/include/AstDOTGeneration.h:12: undefined reference to `vtable for AstDOTGeneration'
./src/useRose.o:(.rodata._ZTV16visitorTraversal[vtable for visitorTraversal]+0x20): undefined reference to `AstSimpleProcessing::evaluateInheritedAttribute(SgNode*, void*)'
./src/useRose.o:(.rodata._ZTV16visitorTraversal[vtable for visitorTraversal]+0x28): undefined reference to `AstSimpleProcessing::evaluateSynthesizedAttribute(SgNode*, void*, StackFrameVector)'
./src/useRose.o:(.rodata._ZTV16visitorTraversal[vtable for visitorTraversal]+0x38): undefined reference to `AstSimpleProcessing::defaultSynthesizedAttribute(void*)'
./src/useRose.o:(.rodata._ZTV16visitorTraversal[vtable for visitorTraversal]+0x40): undefined reference to `AstSimpleProcessing::atTraversalStart()'
./src/useRose.o:(.rodata._ZTI16visitorTraversal[typeinfo for visitorTraversal]+0x10): undefined reference to `typeinfo for AstSimpleProcessing'
./src/useRose.o: In function `SgTreeTraversal::setNodeSuccessors(SgNode*, std::vector&)':
/homes/knoppik/tools/install/rose/include/AstProcessing.h:380: undefined reference to `AstSuccessorsSelectors::selectDefaultSuccessors(SgNode*, std::vector&)'
./src/useRose.o: In function `SgTreeTraversal::setNodeSuccessors(SgNode*, std::vector&)':
/homes/knoppik/tools/install/rose/include/AstProcessing.h:380: undefined reference to `AstSuccessorsSelectors::selectDefaultSuccessors(SgNode*, std::vector&)'
./src/useRose.o: In function `SgTreeTraversal::performTraversal(SgNode*, DOTInheritedAttribute, t_traverseOrder)':
/homes/knoppik/tools/install/rose/include/AstProcessing.h:743: undefined reference to `SgTreeTraversal_inFileToTraverse(SgNode*, bool, SgFile*)'
collect2: ld gab 1 als Ende-Status zurück
make: *** [cpso2cuda] Error 1

**** Build Finished ****

So the rose library seems to be missing, although I told to use them in Project Properties. Can anyone help me solving this? The only difference is that the original building flages are:

-Wl,-rpath-link $(BOOSTLIBDIR) -Wl,-rpath-link $(JAVALIBDIR) -L$(ROSELIBDIR)

And the ones generated by NSight are:

-L/homes/knoppik/tools/install/boost/lib -L/homes/knoppik/tools/install/jdk1.7.0_09/jre/lib/amd64/server -L/homes/knoppik/tools/install/rose/lib -Xlinker -rpath -link -o  "cpso2cuda" $(OBJS) $(USER_OBJS) $(LIBS)

So “rpath-link” is translated to “-XLinker rpath” and “-Wl” is missing. Does anyone know a solution?

Regards
sw

I found out that I can manually changed the automtically by NSight created makefile line from

1st variant

nvcc -L/homes/knoppik/tools/install/boost/lib -L/homes/knoppik/tools/install/jdk1.7.0_09/jre/lib/amd64/server -L/homes/knoppik/tools/install/rose/lib -Xlinker -rpath -link -o "cpso2cuda" $(OBJS) $(USER_OBJS) $(LIBS)

to

2nd variant

nvcc -Xlinker -rpath-link -L/homes/knoppik/tools/install/boost/lib -Xlinker -rpath-link -L/homes/knoppik/tools/install/jdk1.7.0_09/jre/lib/amd64/server -L/homes/knoppik/tools/install/rose/lib -link -o  "cpso2cuda" $(OBJS) $(USER_OBJS) $(LIBS)

But of course each time I rebuild the project the makefile is generated anew.

How can I change the expert settings

${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX} ${OUTPUT} ${INPUTS}

in order to generate the 2nd variant in the automatically generated makefile?

Regards
sw

Hi Steve,
I moved this to the Nsight Eclipse Edition - which is what you meant to do?

Do I correctly understand that the problem you are trying to solve is having -L after -rpath-link?

I got the following command line:

/usr/local/cuda-5.5/bin/nvcc -m64 -Xlinker -rpath-link -L/homes/knoppik/tools/install/boost/lib -Xlinker -rpath-link -L/homes/knoppik/tools/install/jdk1.7.0_09/jre/lib/amd64/server -L/homes/knoppik/tools/install/rose/lib -link -o  "matrixMul"  ./src/main.o

by specifying “-rpath-link -L/homes/knoppik/tools/install/boost/lib” and “-rpath-link -L/homes/knoppik/tools/install/jdk1.7.0_09/jre/lib/amd64/server -L/homes/knoppik/tools/install/rose/lib” as two entries in the -Xlinker option list.