[arch-general] C++ program compiliation failed

Magnus Therning magnus at therning.org
Sun Nov 14 19:25:46 CET 2010


On 14/11/10 17:59, Nilesh Govindarajan wrote:
> Hi,
> I have three c++ files: main.cpp, and querystring.{h,cpp}
>
> querystring.h contains the definition for the QueryString class
> and querystring.cpp contains the implementation.
>
> querystring.cpp and main.cpp both have the statement #include "querystring.h"
>
> Now when I run the compiler, I get a weird error-
>
> $ g++ main.cpp querystring.cpp -o out
> /tmp/ccxJ7C28.o: In function `main':
> main.cpp:(.text+0x3e): undefined reference to `QueryString::QueryString()'
> collect2: ld returned 1 exit status
>
> How am I supposed to compile the program? i.e. in general a multifile
> program having .hs and .cpps

This isn't really the right forum to ask a question like this.  My guess
would
be the order of the files on the command line, try

  $ g++ querystring.cpp main.cpp -o out

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org           Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-general/attachments/20101114/5b50f493/attachment-0001.bin>


More information about the arch-general mailing list