Linker Error Unresolved External Referenced From Unit1.obj
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Borland C++ linker error c file include up vote 2 down vote favorite I'm trying to build a C++ program with borland C++ Builder V5.5. Everything works fine until I tryed to call a function defined in a c file. The compiler works finde but linking is not working. The linker is not able to find the function called from c++ file. The .obj file is gernerated and part of the project xml file. Do anybody now how I can solve this error. To be sure that there are no side effects, I start a new project just calling c function call in constructor. The Project structure looks the following: Form1.h defines Constructor and includes header where the c function is defined Form1.cpp implements Constructor and call the c function test.h defines an void function "void abc();" test.c includes test.h and implements an void function "void abc() {}" Unresolved external "abc()" referenced from ...unit1.obj Do anyone have an idea?? Here some code #include #pragma hdrstop #include "Multicopter_Model.h" #include "Unit1.h" #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { abcdefg(); return; } _ #ifndef RTW_HEADER_Multicopter_Model_h_ #define RTW_HEADER_Multicopter_Model_h_ void abcdefg(); #endif */ _ #include "Multicopter_Model.h" /* Model initialize function */ void abcdefg() { } c++ linker in
out how to fix the following compile error: [Linker Error] Unresolved external 'Malpha::Malpha()' referenced from D:\\MAIN.OBJ My understanding is that this means that the compiler can find the function implementations. I use borland c++builder6. I created some dll's which are needed for the .exe to run. Here is a screenshot (don't know if it would help or not): http://img593.imageshack.us/f/3282011113747pm.png/ All the functions are implemented and tested before I created separate http://stackoverflow.com/questions/11029062/borland-c-linker-error-c-file-include dll's. Please help me because I'm so close! (I hope...) Last edited on Mar 29, 2011 at 9:23am UTC Mar 29, 2011 at 9:05am UTC Bazzy (6281) Are you linking those libraries? Mar 29, 2011 at 9:42am UTC boedy (3) Well.. the function Malpha is included in the machines.dll. I added the .lib file from http://www.cplusplus.com/forum/windows/39536/ machines to app.exe. All the dll's had no problem building, just the app.exe. Not sure if I answered your question though.. Mar 29, 2011 at 11:07am UTC richardforc (42) Will you please check library path and confirm library (machines.dll as you said) is present at that location. Mar 29, 2011 at 1:56pm UTC boedy (3) I seem to have figured out what the problem was. When I was creating the dll's I knew you had to put the following lines at the top of the header files: 1
2
3
4
5
#ifdef __DLL__ #define impexp __declspec(dllexport) #else #define impexp __declspec(dllimport) #endif What I didn't know was you had to put "impex" before the class definition. Well, I Guess thats that. Thanks anyway for taking the time to reply. Cheers! Topic archived. No new replies allowed. C++ Information Tutorials Reference Articles Forum Forum BeginnersWindows ProgrammingUNIX/Linux ProgrammingGeneral C++ ProgrammingLoungeJobs Home page | Privacy policy© cplusplus.com, 2000-2016 - All rights reserved - v3.1Spotted an error? contact us
is related http://www.cplusplus.com/forum/beginner/37219/ to improper usage of functions i suppose. Here is the code:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//--------------------------------------------------------------------------- #include #include #pragma hdrstop int rollDice(); int krepsStat (void); int process (int); //--------------------------------------------------------------------------- #pragma argsused int main(int argc, char* argv[]) { const int arraySize = linker error 1000; cout << "Playing kreps 1000 times gives us the following statistic: \n"; int i, masskrep [arraySize],win=0,loss=0; randomize(); for (i=0;iif (masskrep[i] == 1) win++; else loss++;} cout << "Amount of wins is " << linker error unresolved win<"Amount of losses is "<return 0; } //--------------------------------------------------------------------------- int krepStat() { int gameStatus; int sum; sum = rollDice(); gameStatus = process(sum); if (gameStatus == 1) return 1; else return 0; } int rollDice() { int die1 = 1 + rand()%6; int die2 = 1 + rand()%6; int dice = die1 + die2; return dice; } int process (int sum1) { int gameStatus1,myPoint; switch (sum1){ case 7: case 11: gameStatus1 = 1; break; case 2: case 3: case 12: gameStatus1 = 0; break; default: gameStatus1 = 2; myPoint = sum1; break; } while (gameStatus1 == 2) { sum1 = rollDice(); if (sum1 == myPoint) gameStatus1 = 1; if (sum