digitalmars.D - Using the -I flag in Linux
- PaperPilot (10/10) Dec 27 2007 Hi all:
- Steven Schveighoffer (11/21) Dec 27 2007 You need to include the object file that Word produced. It's just like ...
- PaperPilot (3/20) Dec 27 2007 Does this mean I still have to list all my object files on the command l...
- Jarrett Billingsley (14/16) Dec 27 2007 Only if you don't compile the files that they come from.
- PaperPilot (11/34) Dec 27 2007 I compiled
- =?UTF-8?B?IkrDqXLDtG1lIE0uIEJlcmdlciI=?= (16/35) Dec 27 2007 -----BEGIN PGP SIGNED MESSAGE-----
- PaperPilot (5/11) Dec 27 2007 I've checked out dsss and SCons and they look like reasonable tools. I ...
- Derek Parnell (12/37) Dec 27 2007 And 'Bud' ( http://www.dsource.org/projects/build )
Hi all: I am compiling a D language program in two files and getting an ld error. The files are: hello.d which has the main() routine. Word.d has a class which is instantiated in hello If I compile both files together like: dmd hello Word the program compiles and links successfully. If I compile Word.d first and then hello.d and include the working directory like: dmd hello -I~/sandbox where sandbox is the working directory I get linker errors like: undefined reference to '_D4Word12__ModuleInfoZ' D uses the gcc linker, ld, and I installed gcc 4.1.2 to get it. Is there another package I need to install? Thanks in advance.
Dec 27 2007
"PaperPilot" wroteHi all: I am compiling a D language program in two files and getting an ld error. The files are: hello.d which has the main() routine. Word.d has a class which is instantiated in hello If I compile both files together like: dmd hello Word the program compiles and links successfully. If I compile Word.d first and then hello.d and include the working directory like: dmd hello -I~/sandbox where sandbox is the working directory I get linker errors like: undefined reference to '_D4Word12__ModuleInfoZ'You need to include the object file that Word produced. It's just like a normal C link. Try: dmd hello Word.o -I~/sandbox Note that D still imports via source files (or D interface files), not via object files. So when you import something you are not importing the object into the build, you are simply having the compiler re-parse the source file. This is why it is generally more efficient (time-wise) to compile all your source files at once, as the compiler only parses each file once. This is distinctly different from Java, which imports the compiled file. -Steve
Dec 27 2007
Steven Schveighoffer Wrote:You need to include the object file that Word produced. It's just like a normal C link. Try: dmd hello Word.o -I~/sandbox Note that D still imports via source files (or D interface files), not via object files. So when you import something you are not importing the object into the build, you are simply having the compiler re-parse the source file. This is why it is generally more efficient (time-wise) to compile all your source files at once, as the compiler only parses each file once. This is distinctly different from Java, which imports the compiled file. -SteveDoes this mean I still have to list all my object files on the command line? That could make quite a long entry. Joel
Dec 27 2007
"PaperPilot" <jaltman77096 yahoo.com> wrote in message news:fl0osg$1p1r$1 digitalmars.com...Does this mean I still have to list all my object files on the command line? That could make quite a long entry.Only if you don't compile the files that they come from. i.e. this will work: dmd file1.d file2.d But if you compile them separately: dmd file1.d -c dmd file2.d file1.obj or dmd file1.d file2.d -c dmd file1.obj file2.obj So you only have to list object files of files you don't compile in the same command. This is no different from C or C++.
Dec 27 2007
Jarrett Billingsley Wrote:Only if you don't compile the files that they come from. i.e. this will work: dmd file1.d file2.d But if you compile them separately: dmd file1.d -c dmd file2.d file1.obj or dmd file1.d file2.d -c dmd file1.obj file2.obj So you only have to list object files of files you don't compile in the same command. This is no different from C or C++.I compiled dmd hello.d Word.d -v Both files were parsed. dmd hello.o Word.d -v Word.d was parsed. dmd hello.d Word.o -v Only hello.d was parsed. Then I did: dmd hello.o Word.o -v All I got was an expanded command line. It looks like the object files are passed to the linker no matter when they were generated.
Dec 27 2007
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 PaperPilot wrote:Steven Schveighoffer Wrote:That's why we have tools such as dsss or SCons... Jerome - -- +------------------------- Jerome M. BERGER ---------------------+ | mailto:jeberger free.fr | ICQ: 238062172 | | http://jeberger.free.fr/ | Jabber: jeberger jabber.fr | +---------------------------------+------------------------------+ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFHc/CDd0kWM4JG3k8RAmKpAJ9pTdc6HBA33T9b4mO1A4S2D70pyACgsZ+m wHkywgqTcY2+lp+5xPVp3zk= =jcd4 -----END PGP SIGNATURE-----You need to include the object file that Word produced. It's just like a normal C link. Try: dmd hello Word.o -I~/sandbox Note that D still imports via source files (or D interface files), not via object files. So when you import something you are not importing the object into the build, you are simply having the compiler re-parse the source file. This is why it is generally more efficient (time-wise) to compile all your source files at once, as the compiler only parses each file once. This is distinctly different from Java, which imports the compiled file. -SteveDoes this mean I still have to list all my object files on the command line? That could make quite a long entry.
Dec 27 2007
Jérôme M. Berger Wrote:PaperPilot wrote:I've checked out dsss and SCons and they look like reasonable tools. I will have to try them. Thanks a lot, JoelDoes this mean I still have to list all my object files on the command line? That could make quite a long entry.That's why we have tools such as dsss or SCons... Jerome
Dec 27 2007
On Thu, 27 Dec 2007 19:35:47 +0100, "Jérôme M. Berger" wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 PaperPilot wrote:And 'Bud' ( http://www.dsource.org/projects/build ) Note that the -I switch is used to specify a location for imports. Object files are *not* imported so the -I switch has nothing to do with object files. The full path of each object files is required on the command line, though if that can be expressed as one relative to the current directory you can specify it that way too. The D copmiler does not read object files but merely passes them, as specified, to the linker. -- Derek Parnell Melbourne, Australia skype: derek.j.parnellSteven Schveighoffer Wrote:That's why we have tools such as dsss or SCons...You need to include the object file that Word produced. It's just like a normal C link. Try: dmd hello Word.o -I~/sandbox Note that D still imports via source files (or D interface files), not via object files. So when you import something you are not importing the object into the build, you are simply having the compiler re-parse the source file. This is why it is generally more efficient (time-wise) to compile all your source files at once, as the compiler only parses each file once. This is distinctly different from Java, which imports the compiled file. -SteveDoes this mean I still have to list all my object files on the command line? That could make quite a long entry.
Dec 27 2007