February 06, 2007 Why does DMC not link this correctly? What am I missing. | ||||
---|---|---|---|---|
| ||||
This small example program is not working. I have a feeling dmc does not link header files to there cpp files automaticly. If someone could clue me into what settings I need to make this test file work that would be sweet. There are 3 files: main.cpp, mine.h, mine.cpp CODE:: // main.cpp //--------------------------------- #include <cstdlib> #include <iostream> #include "mine.h" using namespace std; int main(int argc, char *argv[]) { int x = foo(); cout << x << endl; system("PAUSE"); return EXIT_SUCCESS; } //mine.h //------------------------ #ifndef _MINE_H #define _MINE_H int foo(); #endif // mine.cpp // ------------------ #include "mine.h" int foo() { return 5; } I get this error when I try to compile with dmc main.cpp C:\>dmc main.cpp link main,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved main.obj(main) Error 42: Symbol Undefined ?foo@@YAHXZ (int cdecl foo(void )) --- errorlevel 1 |
February 06, 2007 Re: Why does DMC not link this correctly? What am I missing. | ||||
---|---|---|---|---|
| ||||
Posted in reply to johnny masters jr | johnny masters jr skrev: > This small example program is not working. I have a feeling dmc does not link > header files to there cpp files automaticly. Compilers does not normally include .cpp files automaically. I C++ (and C) there is not necessarily any connection between the name of some .h file and some .cpp file. > I get this error when I try to compile with dmc main.cpp > > C:\>dmc main.cpp > link main,,,user32+kernel32/noi; > OPTLINK (R) for Win32 Release 7.50B1 > Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved > > main.obj(main) > Error 42: Symbol Undefined ?foo@@YAHXZ (int cdecl foo(void )) You need to list all the .cpp files on the commandline: dmc main.cpp mine.cpp -- Just another homepage: http://damb.dk But it's mine - Bertel |
Copyright © 1999-2021 by the D Language Foundation