X-Spam-Check-By: sourceware.org Message-ID: <467959EA.5010407@cygwin.com> Date: Wed, 20 Jun 2007 12:46:34 -0400 From: "Larry Hall (Cygwin)" Reply-To: cygwin AT cygwin DOT com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.3) Gecko/20070505 Remi/2.0.0.0-3.fc4.remi Thunderbird/2.0.0.0 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: shared library - undefined symbols References: <307299 DOT 34461 DOT qm AT web30801 DOT mail DOT mud DOT yahoo DOT com> In-Reply-To: <307299.34461.qm@web30801.mail.mud.yahoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Dan O'Brien wrote: > I'm porting a C++ application that builds and runs on linux. This application allows for "plugins" and will dynamically load any shared object found in its plugin directory. This works fine on linux. The trouble I'm having is getting the plugin "shared library" are in to build. I'm running into undefined references (which should be allowed because they will be resolved when the shared library is loaded -- these symbols exist in the main application). > > The failing g++ line: > > g++ -o build/unknown-pc-cygwin/debug/plugin.so -shared -Wl,--allow-shlib-undefined build/unknown-pc-cygwin/debug/.objs/plugin.o build/unknown-pc-cygwin/debug/.objs/NullFilter.o build/unknown-pc-cygwin/debug/.objs/NullFilterFactory.o > > The failing output: > > build/unknown-pc-cygwin/debug/.objs/NullFilter.o: In function `_ZN10NullFilter7processERSt4listI14MatchingPeriodSaIS1_EE': > /home/OBrienDM/gpm/src/NullFilter.cpp:32: undefined reference to `getLoggerVerbosity()' > /home/OBrienDM/gpm/src/NullFilter.cpp:32: undefined reference to `isLoggerEnabledFor(int)' > /home/OBrienDM/gpm/src/NullFilter.cpp:32: undefined reference to `TimeStamp::TimeStamp()' > /home/OBrienDM/gpm/src/NullFilter.cpp:32: undefined reference to `operator<<(std::basic_ostream >&, TimeStamp const&)' > /home/OBrienDM/gpm/src/NullFilter.cpp:32: undefined reference to `TimeStamp::~TimeStamp()' > build/unknown-pc-cygwin/debug/.objs/NullFilter.o: In function `_ZN10NullFilter7processERSt4listI14MatchingPeriodSaIS1_EE': > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/sstream:511: undefined reference to `log(int, std::basic_string, std::allocator > const&, char const*, unsigned int)' > build/unknown-pc-cygwin/debug/.objs/NullFilter.o: In function `_ZN10NullFilter7processERSt4listI14MatchingPeriodSaIS1_EE': > /home/OBrienDM/gpm/src/NullFilter.cpp:32: undefined reference to `TimeStamp::~TimeStamp()' > build/unknown-pc-cygwin/debug/.objs/NullFilterFactory.o: In function `_ZN17NullFilterFactoryC1Ev': > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/ext/new_allocator.h:62: undefined reference to `MatcherFactory::instance()' > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/ext/new_allocator.h:62: undefined reference to `MatcherFactory::registerFilterFactory(std::basic_string, std::allocator >, FilterFactoryAdapter*)' > build/unknown-pc-cygwin/debug/.objs/NullFilterFactory.o: In function `_ZN17NullFilterFactoryC2Ev': > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/ext/new_allocator.h:62: undefined reference to `MatcherFactory::instance()' > /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/ext/new_allocator.h:62: undefined reference to `MatcherFactory::registerFilterFactory(std::basic_string, std::allocator >, FilterFactoryAdapter*)' > collect2: ld returned 1 exit status > > These missing references are found in the executable: > > nm --demangle ./build/unknown-pc-cygwin/debug/gpm.exe |grep 'getLoggerVerbosity()' > 00456820 T getLoggerVerbosity() > nm --demangle ./build/unknown-pc-cygwin/debug/gpm.exe |grep 'TimeStamp::~TimeStamp()' > 004b4470 T TimeStamp::~TimeStamp() > 004b4460 T TimeStamp::~TimeStamp() > > And will get resolved at load time. > > The g++ line works fine under linux. > > Any other flags I'm missing? > DLLs are not SOs. DLLs must resolve all symbols at link time. That's why Windows has the concept of export libraries. See MSDN documentation for a discussion of this. So essentially, you'll need to have one or more export libraries with stubs to the missing symbols in them. List them when compiling your plugin. That will resolve the issue. -- Larry Hall http://www.rfk.com RFK Partners, Inc. (508) 893-9779 - RFK Office 216 Dalton Rd. (508) 893-9889 - FAX Holliston, MA 01746 _____________________________________________________________________ A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting annoying in email? -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/