Linking C++ and Cilk++ files.

Linking C++ and Cilk++ files.

I was trying to use a classfromsepeate C++ code in my Cilk++ code, and encountered compilation errors. Adding the following code at the beginning of Cilk++ code to include both header and C++ code fixed the problem. Thanks. -Hailong


3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Good tip. As a general rule, if the Cilk++ code can be isolated effectively, apart from alleviating some of the integration difficulties, you may see performance improvements.

That aside, I'd be interested to know what the compilation errors were. Were they linker errors?

Thanks for the advice. If I don't include the cpp file in Cilk++ code and try to link the object files as below:

$ g++ -c mycode.cpp
$ cilk++ -c newcode.cilk
$ cilk++ mycode.o newcode.o -o newcode.exe -O2

I would not pass the second command line. Say I have a class called myclass implemented in mycode.cpp then I would encouter errors like "myclasshas not beedeclared" or "myclass was notdeclared in this scope".

When I included both the cpp and header file in the Cilk++ code, I was able to compile the Cilk++ code in one step with no errors:

cilk++ newcode.cilk -o newcode.exe -O2


Leave a Comment

Please sign in to add a comment. Not a member? Join today