[C/C++] External Linker Error met BCC

Pagina: 1
Acties:

  • TheCameleon
  • Registratie: Juni 2001
  • Laatst online: 20-08 22:50
Heb al weken een dom *** probleem. Ik wil gewoon in het algemeen een console applicatie voor win32 (XP om precies te zijn) compilen. Eerst geprobeerd met Borland C Builder op school, maar dir's stonden raar en gaf een linker error. Daarna op visual C geprobeerd maar idem. Dus thuis maar verder geprobeerd

De preciese melding komt zodra ik een los obj file (aangeleverd door school) wil gebruiken (met een .h file). En dit is hem:
Error: Unresolved external '_WordStore_Clear' referenced from C:\CPRG\TEST.OBJ

Nu thuis maar ff BCC32 (gratis van Borland) er op gepleurd om te compilen en ik gebruik hem zoals hieronder:

BCC32 -q -nC:\CPrg -IC:\Borland\BCC55\Include -LC:\Borland\BCC55\Lib\ C:\CPrg\Test.c

Op het volgende bestandje:

C++:
1
2
3
4
5
6
7
#include "WordStore.H"

int main (void)
{
  printf("Test\n");
  WordStore_Clear();
}


Toen gaf hij dus nog steeds dezelfde melding
Voor diegen die de volledige meldingen willen hebben van BCC:

code:
1
2
3
4
5
"C:\Borland\BCC55\Bin\bcc32.exe" -q -nC:\CPrg -IC:\Borland\BCC55\Include -LC:\Borland\BCC55\Lib\ C:\CPrg\Test.c
C:\CPrg\Test.c:
Warning W8065 C:\CPrg\Test.c 5: Call to function 'printf' with no prototype in function main
Warning W8070 C:\CPrg\Test.c 7: Function should return a value in function main
Error: Unresolved external '_WordStore_Clear' referenced from C:\CPRG\TEST.OBJ


Verder heb ik ook nog lopen prutsen door het volgende ilink32.cfg bestandje aan te maken in de bin dir van bcc:

code:
1
2
3
4
-q
-jC:\CPrg;C:\Borland\BCC55\Lib
-IC:\CPrg
-GC:\CPrg\WordStore.obj


maar ook dat had geen resultaat.
GRAAG HELP WANT IK ZIE HET NIET MEER ZITTEN ;( :p

edit:

Ohja, Wordstore.h en WordStore.obj stan uiteraard allebei in dezelfde dir als Test.c maar daar was je den kik al achter. En die dir is C:\CPrg

[ Voor 8% gewijzigd door TheCameleon op 14-10-2003 23:41 ]


  • .oisyn
  • Registratie: September 2000
  • Laatst online: 12:02

.oisyn

Moderator Devschuur®

Demotivational Speaker

uhm, en hoe denk jij dat wij jou kunnen gaan helpen als we de inhoud van WordStore.h niet kennen?

en je moet natuurlijk ook wel linken met WordStore.obj, dat doet ie niet automatisch

Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.


  • TheCameleon
  • Registratie: Juni 2001
  • Laatst online: 20-08 22:50
Kun je mij dan even dat laatste toelichten.. Ken ik namelijk niet (Ja ik ken niet veel van C...)
En dat wordstore.h kan ik nog wel toevoegen als dat niet werkt, maar is vrij lang dus in een bericht lijkt me niet handig

  • TheCameleon
  • Registratie: Juni 2001
  • Laatst online: 20-08 22:50
Hier dan toch maar.. maar ik hoop dat het nog wat over laat van de rest van het forum.
You're wish is my command :p

C++:
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*************************************/
/**                                 **/
/**   File:    WORDSTORE.H          **/
/**   Author:  F.H.J. Feldbrugge    **/
/**   Version: 1.0                  **/
/**   Date:    Aug 12, 2001         **/
/**                                 **/
/*************************************/

#ifndef WORDSTORE_H
#define WORDSTORE_H

#include "Boolean.h"

#define MAXLEN_WORD 20

/*
** WordStore can be seen as a circular list of words.
** There is a virtual pointer, dubbed Current Word, which points to
** one of the words in the list (if the list is non-empty).
*/

void WordStore_Clear (void);
    /*
    ** Removes all words from WordStore.
    ** pre:  -
    ** post: WordStore_NrWords == 0
    */

Boolean WordStore_FileRead (char sFileName[]);
    /*
    ** Reads all non-empty words from the file with name sFileName and
    ** inserts these words to WordStore (see function WordStore_WordInsert
    ** for a description of how a word is inserted).
    ** pre:  sFileName contains syntactically valid file name.
    ** post: WordStore_FileRead (f) == TRUE
    **           ==> all words of file added to WordStore.
    */

Boolean WordStore_FileWrite (char sFileName[]);
    /*
    ** Writes all words (from the Current Word onwards) to a file with
    ** name sFileName.  If the file could not be opened or created,
    ** the value FALSE is returned, TRUE otherwise.
    ** pre:  sFileName contains syntactically valid file name.
    ** post: WordStore_FileWrite (f) == TRUE
    **           ==> File contains all words of WordStore.
    */

void WordStore_MoveBackward (void);
    /*
    ** Moves the Current Word pointer to the previous word in WordStore.
    ** pre:  -
    ** post: Current Word moved one position backward.
    */

void WordStore_MoveForward (void);
    /*
    ** Moves the Current Word pointer to the next word in WordStore.
    ** pre:  -
    ** post: Current Word moved one position forward.
    */

void WordStore_MoveRandom (void);
    /*
    ** Moves Current Word to random word.
    ** pre:  -
    ** post: If WordStore is not empty, Current Word is randomly
    **       selected word.
    */

int WordStore_NrWords (void);
    /*
    ** Returns the number of words in WordStore.
    ** pre:  -
    ** post: WordStore_NrWords () == number of words in WordStore
    */

void WordStore_Sort (void);
    /*
    ** Sorts all words in WordStore in ascending order and locates
    ** the Current Word on the lowest word.
    ** pre:  -
    ** post: Words sorted and Current Word is lowest word.
    */

char *WordStore_WordDelete (void);
    /*
    ** Returns Current Word to caller, deletes the word from WordStore
    ** and selects the next word to be the Current Word.
    ** If WordStore was empty, NULL is returned.
    ** pre:  -
    ** post: If WordStore_WordDelete () == NULL
    **       then WordStore is empty
    **       else WordStore_WordDelete () == pointer to former Current Word
    **            and former Current Word deleted from WordStore
    **            and next word in WordStore is new Current Word
    */

void WordStore_WordInsert (char *pcWord);
    /*
    ** Inserts word, pointed to by pcWord, to WordStore at the position
    ** after the Current Word.  Afterwards the newly inserted word becomes
    ** the Current Word.
    ** Note that the pointer pcWord is stored; the
    ** word is not copied to newly allocated memory space!
    ** pre:  Sufficient heap space available.
    ** post: pcWord inserted at position of Current Word.
    */

char *WordStore_WordRead (void);
    /*
    ** Returns Current Word to caller (without deleting the word
    ** from WordStore).
    ** If WordStore was empty, NULL is returned.
    ** pre:
    ** post: If WordStore_WordRead () == NULL
    **       then WordStore is empty
    **       else WordStore_WordRead () == pointer to Current Word
    */

#endif

En ik zag al in mijn preview dat het mee valt

  • .oisyn
  • Registratie: September 2000
  • Laatst online: 12:02

.oisyn

Moderator Devschuur®

Demotivational Speaker

Je moet gewoon WordStore.obj meegeven als extra parameter naar je compiler. Heb je geen IDE waarin je dat in kunt stellen?

Give a man a game and he'll have fun for a day. Teach a man to make games and he'll never have fun again.


  • TheCameleon
  • Registratie: Juni 2001
  • Laatst online: 20-08 22:50
-oxxx Object file name

Maar dat heb ik al geprobeerd. Tenzij je iets anders ziet:
Hier alle parameters van mijn compiler (mischien zie ik iets over het hoofd)

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
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
Syntax is: BCC32 [ options ] file[s]     * = default; -x- = turn switch
  -3    * 80386 Instructions        -4      80486 Instructions
  -5      Pentium Instructions      -6      Pentium Pro Instructions
  -Ax     Disable extensions        -B      Compile via assembly
  -C      Allow nested comments     -Dxxx   Define macro
  -Exxx   Alternate Assembler name  -Hxxx   Use pre-compiled headers
  -Ixxx   Include files directory   -K      Default char is unsigned
  -Lxxx   Libraries directory       -M      Generate link map
  -N      Check stack overflow      -Ox     Optimizations
  -P      Force C++ compile         -R      Produce browser info
  -RT   * Generate RTTI             -S      Produce assembly output
  -Txxx   Set assembler option      -Uxxx   Undefine macro
  -Vx     Virtual table control     -X      Suppress autodep. output
  -aN     Align on N bytes          -b    * Treat enums as integers
  -c      Compile only              -d      Merge duplicate strings
  -exxx   Executable file name      -fxx    Floating point options
  -gN     Stop after N warnings     -iN     Max. identifier length
  -jN     Stop after N errors       -k    * Standard stack frame
  -lx     Set linker option         -nxxx   Output file directory
  -oxxx   Object file name          -p      Pascal calls
  -tWxxx  Create Windows app        -u    * Underscores on externs
  -v      Source level debugging    -wxxx   Warning control
  -xxxx   Exception handling        -y      Produce line number info

  • _js_
  • Registratie: Oktober 2002
  • Laatst online: 13-01 07:19
Je krijgt een linker error, dus je moet in de linker de optie aangeven, misschien lukt het met -lx, anders met -c en dan je linker apart aanroepen.

  • TheCameleon
  • Registratie: Juni 2001
  • Laatst online: 20-08 22:50
Ik zit nu niet achter mijn pc dus ga het vanavond proberen. Maar ik probeer het dan wel in mijn ilink32.cfg te zetten. Dan hoef je -c niet te gebruiken en kun je ook je opties aangeven.

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 13-08 16:46

curry684

left part of the evil twins

Dit heeft niets met Win32 van doen ;)

Een applicatie 'builden' met C of C++ bestaat uit 2 stappen: compileren en linken. Tijdens de compileerstap wordt er een 1-op-1 vertaling gedaan, voor ieder c/cpp/cxx bestand dat je opgeeft wordt een .obj bestand aangemaakt. Deze .obj bevat vervolgens alle gecompileerde machinecode, en een hoop 'external references', oftewel verwijzingen naar code die niet in dezelfde .obj zit.

De linker vervolgens pakt de hele vergaarbak van .obj files en maakt er 1 grote executable van. Het linkproces bestaat voornamelijk uit het 'resolven' van die external references, oftewel het aan mekaar plakken van de losse eindjes tussen objecten.

Als je een benodigde obj niet meelinkt blijft er dus een open eindje achter omdat de betreffende code niet aanwezig is: oftewel een 'unresolved external reference'.

Professionele website nodig?


  • TheCameleon
  • Registratie: Juni 2001
  • Laatst online: 20-08 22:50
Ik vind het allemaal nu een heel mooi verhaal en begrijp het wel...
Echter heb ik nog steeds geen m,anier gevonden om het voor elkaar te krijgen met BCC en ilink

heb er voor de duidelijkheid ook maar ff de parameters van ilink bijgedaan

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
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Syntax: ILINK32 objfiles, exefile, mapfile, libfiles, deffile, resfiles
@xxxx indicates use response file xxxx
General Options:                        -Af:nnnn Specify file alignment
  -C       Clear state before linking   -Ao:nnnn Specify object alignment
  -wxxx    Warning control              -ax      Specify application type
  -Enn     Max number of errors         -b:xxxx  Specify image base addr
  -r       Verbose linking              -Txx     Specify output file type
  -q       Supress banner               -H:xxxx  Specify heap reserve size
  -c       Case sensitive linking       -Hc:xxxx Specify heap commit size
  -v       Full debug information       -S:xxxx  Specify stack reserve size
  -Gn      No state files               -Sc:xxxx Specify stack commit size
  -Gi      Generate import library      -Vd.d    Specify Windows version
  -GD      Generate .DRC file           -Dstring Set image description
Map File Control:                       -Vd.d    Specify subsystem version
  -M       Map with mangled names       -Ud.d    Specify image user version
  -m       Map file with publics        -GC      Specify image comment string
  -s       Detailed segment map         -GF      Set image flags
  -x       No map                       -Gl      Static package
Paths:                                  -Gpd     Design time only package
  -I       Intermediate output dir      -Gpr     Runtime only package
  -L       Specify library search paths -GS      Set section flags
  -j       Specify object search paths  -Gt      Fast TLS
Image Control:                          -Gz      Do image checksum
  -d       Delay load a .DLL            -Rr      Replace resources

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 13-08 16:46

curry684

left part of the evil twins

Syntax: ILINK32 objfiles, exefile, mapfile, libfiles, deffile, resfiles
Wat snap je nu eigenlijk niet? Moeten we de commandlines nu ook nog uitschrijven? :?

Professionele website nodig?


  • farlane
  • Registratie: Maart 2000
  • Laatst online: 18:33
Probeer het eens met make dan ......

Somniferous whisperings of scarlet fields. Sleep calling me and in my dreams i wander. My reality is abandoned (I traverse afar). Not a care if I never everwake.


  • TheCameleon
  • Registratie: Juni 2001
  • Laatst online: 20-08 22:50
curry684 schreef op 15 October 2003 @ 15:50:
[...]

Wat snap je nu eigenlijk niet? Moeten we de commandlines nu ook nog uitschrijven? :?
Snap het wel, krijg alleen geen geldig win32 executable.. lijkt me niet goed dus!
Pagina: 1