简体   繁体   English

未定义符号链接器turbo c

[英]undefined symbol linker turbo c

I'm programming a queue of my own struct data type in Turbo C++ 3.0, I can't build my project because TC presents me an error message of Undefined symbol when it try to linked it. 我正在Turbo C ++ 3.0中对自己的结构数据类型的队列进行编程,所以无法构建我的项目,因为TC在尝试链接它时会向我显示未定义符号的错误消息。

I have the following queue.h file 我有以下queue.h文件

#include <stdio.h>
struct pcb{
    int *QueueBase;
    char id;
    int quantum;
};

typedef struct pcb far * ppcb;
typedef struct nodocola far * pnodocola;

struct nodocola{
    ppcb a;
    pnodocola ant;
};
void insertProcess(ppcb arg1);
ppcb getProcess();

And my file queue.cpp 还有我的文件queue.cpp

#include<stdlib.h>
#include<stdio.h>
#include<cola.h>
struct pcb{
    int *QueueBase;
    char id;
    int quantum;
};

typedef struct pcb far * ppcb;
typedef struct nodocola far * pnodocola;

struct nodocola{
    ppcb a;
    pnodocola ant;
};

pnodocola base = (pnodocola)malloc(sizeof(pnodocola*));

void insertProcess(ppcb arg1){
    base->a = arg1;
    pnodocola tmp = (pnodocola)malloc(sizeof(pnodocola*));
    tmp = base;
    base = (pnodocola)malloc(sizeof(pnodocola*));
    base->ant = tmp;
}

ppcb getProcess(){
    pnodocola tmp = (pnodocola)malloc(sizeof(pnodocola*));
    tmp = base->ant;
    base = tmp->ant;
    return tmp->a;
}

And the file where I include my file queue.h: 以及包含我的文件queue.h的文件:

#include<queue.h>
#include<dos.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<iostream.h>

void interrupt myTimer(...);
void interrupt (*prev)(...);
ppcb actual = (ppcb)malloc(sizeof(ppcb*));
int ticks;
const quantum = 4;

void main()
{
    clrscr();
    prev=getvect(8);
    setvect(8,myTimer);
    getch();
    disable();
    setvect(8,prev);
    enable();
}

void interrupt myTimer(...)
{
    (*prev)();      
}

void init(...)
{
    actual->id='A';
    actual->quantum = quantum;
    insertProcess(actual);
}

Error: Undefined symbol insertProcess(ppcb far )* 错误:未定义符号insertProcess(ppcb far )*

I'm working in a virtual machine with Windows XP 32 bits. 我正在使用Windows XP 32位虚拟机。

Edit: Sorry I have a mistake, I rename my file from cola.h to queue.h when I write the question, but the #include is correctly and the error is present. 编辑:对不起,我有一个错误,我在写问题时将文件从cola.h重命名为queue.h,但#include正确并且存在错误。

And are you actually linking with the object file produced by queue.cpp ? 并且您实际上是在链接 queue.cpp生成的目标文件吗? It's not enough to just include the header file in your main code, you have to link both the main code and the queue code when you create the executable. 仅在主代码中包含头文件是不够的,创建可执行文件时必须同时链接主代码和队列代码。

And, as an aside, why are you using such an archaic C implementation when far better, far more modern and just-as-cheap options are available? 而且,顺便说一句,当可以使用更好,更现代且最便宜的选项时,为什么还要使用这种过时的C实现?


In order to make Turbo C compile multiple source files, I think you have to create a project and then add the C files to that project. 为了使Turbo C可以编译多个源文件,我认为您必须创建一个项目,然后将C文件添加到该项目中。 It will then know it has to compile and link all those source files in the project. 然后它将知道它必须编译并链接项目中的所有那些源文件。

If you just have a single source file (no project), it treats it as a project with just that file. 如果您只有一个源文件(没有项目),则将其视为仅包含该文件的项目。

您说您包括“ queue.h”,但在相关文件中的任何地方都看不到#include "queue.h"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM