Thread: [Dev-C++] Still more linker problems...
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Siva C. <siv...@ya...> - 2004-06-03 11:15:25
|
Hello, I am still trying to solve my linker problems. I am trying to do the following: 1. Build a static library; For this I use a header file say x.h. This header file contains few inline functions( and of-course their definitions). So I comfortably compile all the source files, then put them together as libx.a file. The going is great so far!! 2. Next I try to use this library in an application. So I create a source file and compile it. Its all too simple and I get an object file, say, appx.o. Note that I include the header x.h in my source file. 3. Now I try to link my object file appx.o with libx.a. Here is where I am stuck. The linker complains about all the inline functions defined in x.h to be multiple-ly defined. Can somebody please help me out in getting around this problem!! TIA, Siva Chandra ------------------------------------------------------- PS :: The problem I am facing is while try to build OpenCV and its support libs. ------------------------------------------------------- __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ |
|
From: Scott S. <age...@co...> - 2004-06-03 14:42:32
|
I think it is because you are putting the definitions in the .h file. Instead, it would be better to make x.h have only variable declarations, defines, and function prototypes, and an x.cpp file which has all the function definitions. What is happening is that the definitions are being held in the libx.a file and in the header, and thus the compiler doesn't know which definition to use. SO the choices here are to put all the definitions in an x.cpp file, or just use one big header for everything. -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Siva Chandra Sent: Thursday, June 03, 2004 7:15 AM To: dev...@li... Subject: [Dev-C++] Still more linker problems... Hello, I am still trying to solve my linker problems. I am trying to do the following: 1. Build a static library; For this I use a header file say x.h. This header file contains few inline functions( and of-course their definitions). So I comfortably compile all the source files, then put them together as libx.a file. The going is great so far!! 2. Next I try to use this library in an application. So I create a source file and compile it. Its all too simple and I get an object file, say, appx.o. Note that I include the header x.h in my source file. 3. Now I try to link my object file appx.o with libx.a. Here is where I am stuck. The linker complains about all the inline functions defined in x.h to be multiple-ly defined. Can somebody please help me out in getting around this problem!! TIA, Siva Chandra ------------------------------------------------------- PS :: The problem I am facing is while try to build OpenCV and its support libs. ------------------------------------------------------- __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |
|
From: Siva C. <siv...@ya...> - 2004-06-03 15:49:16
|
Hello Scott, --- Scott Simontis <age...@co...> wrote: > I think it is because you are putting the > definitions in the .h file. > Instead, it would be better to make x.h have only > variable declarations, > defines, and function prototypes, and an x.cpp file > which has all the > function definitions. But aren't inline functions supposed to be defined in the header files itself?...!! ...if no, then how would the compiler know the function definition to generate code in-line? /Siva Chandra > -----Original Message----- > From: dev...@li... > On Behalf Of Siva Chandra > Subject: [Dev-C++] Still more linker problems... > > Hello, > > I am still trying to solve my linker problems. I am > trying to do the following: > > 1. Build a static library; > For this I use a header file say x.h. This header > file > contains few inline functions( and of-course their > definitions). So I comfortably compile all the > source > files, then put them together as libx.a file. The > going is great so far!! > > 2. Next I try to use this library in an application. > So I create a source file and compile it. Its all > too > simple and I get an object file, say, appx.o. Note > that I include the header x.h in my source file. > > 3. Now I try to link my object file appx.o with > libx.a. > Here is where I am stuck. The linker complains about > all the inline functions defined in x.h to be > multiple-ly defined. > > Can somebody please help me out in getting around > this > problem!! > > TIA, > > Siva Chandra > ------------------------------------------------------- > PS :: The problem I am facing is while try to build > OpenCV and its support libs. > ------------------------------------------------------- __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ |
|
From: Per W. <pw...@ia...> - 2004-06-03 16:23:06
|
When you create a library, you are supposted to _link_ to the functions in the library. What use is a library if you are using inline functions? Then you don't need a library but may just include the header file. /Per W On Thu, 3 Jun 2004, Siva Chandra wrote: > > Hello Scott, > > --- Scott Simontis <age...@co...> wrote: > > I think it is because you are putting the > > definitions in the .h file. > > Instead, it would be better to make x.h have only > > variable declarations, > > defines, and function prototypes, and an x.cpp file > > which has all the > > function definitions. > > But aren't inline functions supposed to be defined in > the header files itself?...!! > > ...if no, then how would the compiler know the > function definition to generate code in-line? > > /Siva Chandra > > > -----Original Message----- > > From: dev...@li... > > On Behalf Of Siva Chandra > > Subject: [Dev-C++] Still more linker problems... > > > > Hello, > > > > I am still trying to solve my linker problems. I am > > trying to do the following: > > > > 1. Build a static library; > > For this I use a header file say x.h. This header > > file > > contains few inline functions( and of-course their > > definitions). So I comfortably compile all the > > source > > files, then put them together as libx.a file. The > > going is great so far!! > > > > 2. Next I try to use this library in an application. > > So I create a source file and compile it. Its all > > too > > simple and I get an object file, say, appx.o. Note > > that I include the header x.h in my source file. > > > > 3. Now I try to link my object file appx.o with > > libx.a. > > Here is where I am stuck. The linker complains about > > all the inline functions defined in x.h to be > > multiple-ly defined. > > > > Can somebody please help me out in getting around > > this > > problem!! > > > > TIA, > > > > Siva Chandra > > > ------------------------------------------------------- > > PS :: The problem I am facing is while try to build > > OpenCV and its support libs. > > > ------------------------------------------------------- > > > > > > __________________________________ > Do you Yahoo!? > Friends. Fun. Try the all-new Yahoo! Messenger. > http://messenger.yahoo.com/ > > > ------------------------------------------------------- > This SF.Net email is sponsored by the new InstallShield X. > >From Windows to Linux, servers to mobile, InstallShield X is the one > installation-authoring solution that does it all. Learn more and > evaluate today! http://www.installshield.com/Dev2Dev/0504 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
|
From: Siva C. <siv...@ya...> - 2004-06-03 16:32:56
|
Hello, --- Per Westermark <pw...@ia...> wrote: > When you create a library, you are supposted to > _link_ to the functions in > the library. What use is a library if you are using > inline functions? The library( I created a hypothetical situation, but I was trying to build OpenCV) and the header file has other non-inline functions too. This header comes along with 100-odd C++ source files which define the other non-inline functions declared in the header. So I followed the normal procedure and compiled and ar'ed them into a *.a file! Siva Chandra __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ |
|
From: Per W. <pw...@ia...> - 2004-06-03 20:15:00
|
It's a bit strange, because the inline functions should generate code placed in Common segments, and the linker should accept multiple definitions of symbols in Common segments as long as the Common blocks are identical. It's only with --warn-common that the linker should emit a warning for a symbol available in more than one Common block. /Per W On Thu, 3 Jun 2004, Siva Chandra wrote: > > Hello, > > --- Per Westermark <pw...@ia...> wrote: > > When you create a library, you are supposted to > > _link_ to the functions in > > the library. What use is a library if you are using > > inline functions? > > The library( I created a hypothetical situation, but I > was trying to build OpenCV) and the header file has > other non-inline functions too. This header comes > along with 100-odd C++ source files which define the > other non-inline functions declared in the header. So > I followed the normal procedure and compiled and ar'ed > them into a *.a file! > > Siva Chandra > > > > > > __________________________________ > Do you Yahoo!? > Friends. Fun. Try the all-new Yahoo! Messenger. > http://messenger.yahoo.com/ > > > ------------------------------------------------------- > This SF.Net email is sponsored by the new InstallShield X. > >From Windows to Linux, servers to mobile, InstallShield X is the one > installation-authoring solution that does it all. Learn more and > evaluate today! http://www.installshield.com/Dev2Dev/0504 > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |