- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to build a shared libary that's a mix of C and C++ files. I can't get it to link. Here's the build, and the errors:
icc -std=c99 -I/opt/crc/R/R-2.15.0-intel/inst/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -std=c99 -c csemnlm.c -o csemnlm.o
icc -std=c99 -I/opt/crc/R/R-2.15.0-intel/inst/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -std=c99 -c uncmin.c -o uncmin.o
icpc -I/opt/crc/R/R-2.15.0-intel/inst/lib64/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -c csem.cpp -o csem.o
icpc -L/usr/local/lib64 -o sem.so csemnlm.o uncmin.o csem.o -g -O2 -lm -L/opt/crc/R/R-2.15.0-intel/inst/lib64/R/lib -lRlapack -L/opt/crc/R/R-2.15.0-intel/inst/lib64/R/lib -lRblas -lifport -lifcore -limf -lsvml -lm -lipgo -lirc -lpthread -lirc_s -ldl -L/opt/crc/R/R-2.15.0-intel/inst/lib64/R/lib -lR
/afs/crc.nd.edu/x86_64_linux/intel/12.0/composerxe-2011.2.137/compiler/lib/intel64/libimf.so: warning: warning: feupdateenv is not implemented and will always fail
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
make: *** [sem.so] Error 1
Since the error comes trying to link a to gcc library on the system, my first guess is that cpc is having troubles doing this ( I've see old postings to this effect.)
My Second guess would be that I can't us cpc to link c and C++
Any ideas appreciated,
Mark
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you're trying to create a shared library don't you need to use the options -shared -Wl,soname,libsem.so instead of -o sem.so?
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is the way that you can create and use shared libs(.so):-
1. Compile the source file(.c or .cpp) example :- icpc -c -fPIC func1.cpp
//func1.cpp
#include
#include "func1.h"
using namespace std;
int call_func1()
{
cout<<"static func1 was called";
return 12;
}
//func1.h
int call_func1();
Then take the object file created (func1.o) and use it in the prescribed way:-
//main1.c
#include
#include "func1.h"
int main()
{
call_func1();
return 0;
}
icpc func1.o -shared -o libshare.so
icpc main1.c ./libshare.so //OK
icpc main1.c //main1.c:(.text+0x29): undefined reference to `call_func1()'
This is the way we generally create and use shared libraries. If you have any further doubts please do let me know and i would be happy to help you.
OS used ubuntu 10.04 LTS.
Thanks & Regards,
Sukruth H.V
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi, I am building Gromacs 5.0.4 with intel compilers.
mpiicc -v
mpiicc for the Intel(R) MPI Library 4.1 for Linux*
Copyright(C) 2003-2013, Intel Corporation. All rights reserved.
icc version 14.0.1 (gcc version 4.4.6 compatibility)
i am using two flag options -nostartfiles -g
i am getting the error :
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
Where is the error coming from?
thanks in advance.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page