delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/07/04/07:09:05

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4C306BC0.6000708@ltu.se>
Date: Sun, 04 Jul 2010 13:08:48 +0200
From: Bengt-Arne Fjellner <Bengt-Arne DOT Fjellner AT ltu DOT se>
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.1.10) Gecko/20100512 Thunderbird/3.0.5
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Building DLLs on C++ version code failed, but okay on C version code.
References: <29068199 DOT post AT talk DOT nabble DOT com> <29068213 DOT post AT talk DOT nabble DOT com>
In-Reply-To: <29068213.post@talk.nabble.com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 2010-07-04 12:27 PM, kenny AT ca wrote:
> Forgot to attach error information.
>
> hello.o:hello.cpp:(.text+0xd): undefined reference to
> `std::basic_string<char, std::char_traits<char>, std::allocator<char>
>    
>> ::size() const'
>>      
> hello.o:hello.cpp:(.text+0x60): undefined reference to
> `std::basic_string<char, std::char_traits<char>, std::allocator<char>
>    
>> ::operator[](unsigned int) const'
>>      
> hello.o:hello.cpp:(.text+0x9f): undefined reference to
> `std::basic_string<char, std::char_traits<char>, std::allocator<char>
>    
>> ::operator[](unsigned int) const'
>>      
> hello.o:hello.cpp:(.text+0xce): undefined reference to
> `std::basic_string<char, std::char_traits<char>, std::allocator<char>
>    
>> ::operator[](unsigned int) const'
>>      
> hello.o:hello.cpp:(.text+0x111): undefined reference to `std::cout'
> hello.o:hello.cpp:(.text+0x116): undefined reference to
> `std::basic_ostream<char, std::char_traits<char>  >&  std::operator<<
> <std::char_traits<char>  >(std::basic_ostream<char, std::char_traits<char>
>    
>> &, char const*)'
>>      
> hello.o:hello.cpp:(.text+0x11e): undefined reference to
> `std::basic_ostream<char, std::char_traits<char>  >&  std::endl<char,
> std::char_traits<char>  >(std::basic_ostream<char, std::char_traits<char>
>    
>> &)'
>>      
> hello.o:hello.cpp:(.text+0x126): undefined reference to
> `std::basic_ostream<char, std::char_traits<char>
>    
>> ::operator<<(std::basic_ostream<char, std::char_traits<char>  >&
>>      
> (*)(std::basic_ostream<char, std::char_traits<char>  >&))'
> hello.o:hello.cpp:(.text+0x149): undefined reference to
> `std::ios_base::Init::Init()'
> hello.o:hello.cpp:(.text+0x164): undefined reference to
> `std::ios_base::Init::~Init()'
> collect2: ld returned 1 exit status
>
>
> kenny AT ca wrote:
>    
>> Hi there,
>>
>> I wrote a file, hello.c. It has only one function: print a message like
>> "hello!".
>> ##### hello.c #########
>> #include<stdio.h>
>> void hello() { printf( "Hello.\n" ) ; }
>>
>> $gcc -c hello.c
>> $gcc -shared -o hello.dll hello.o
>>
>> I successufully built it as DLL, hello.dll.
>>
>> Then, I rewrote it in c++.
>> ##### hello.cpp #######
>> #include<iostream>
>> using namespace std ;
>> void hello() {cout<<  "Hello."<<  endl ;}
>>
>> Then, I used the commands above to built DLL, but it failed. Why did it
>> fail?
>>
>>
>>      
>    
Use g++ to compile and link c++ code


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019