[英]Undefined reference to 'function' using CodeBlocks
我用一個簡單的項目開始學習 CodeBlocks 時出現以下錯誤。
E:\CodeBlocks\Projects\Triplet-CLEON-Benjamin\main.c|5|undefined reference to `initTriplet'|
C:\msys64\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\12.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: E:\CodeBlocks\Projects\Triplet-CLEON-Benjamin\main.c|7|undefined reference to `AfficheTriplet'|
我的項目中只有 3 個文件,分別是:
主程序
#include "triplet.h"
int main()
{
triplet myTriplet = initTriplet(5,8,7);
AfficheTriplet(myTriplet);
return 0;
}
三胞胎.c
#include "triplet.h"
#include <stdio.h>
void AfficheTriplet(triplet myTriplet)
{
printf("Triplet: \n\t Premier %d\n\t Second %d\n\t Troisieme %d", myTriplet.p, myTriplet.d, myTriplet.t);
}
triplet initTriplet(int a, int b, int c)
{
triplet myTriplet = {a,b,c};
return myTriplet;
}
三元組
#ifndef TRIPLET_H_INCLUDED
#define TRIPLET_H_INCLUDED
typedef struct triplet triplet;
struct triplet
{
int p;
int d;
int t;
};
triplet triTripletV1(triplet myTriplet);
void triTripletV2(triplet myTriplet);
void AfficheTriplet(triplet myTriplet);
triplet initTriplet(int a, int b, int c);
#endif // TRIPLET_H_INCLUDED
在我的主文件中,如果我包含三元組,則如果我包含triplet.h,則運行其他工作,我有以前的錯誤。
此外,我的項目構建為
請問有什么幫助嗎?
我在 CodeBlocks 中編譯你的應用程序沒有任何問題,所以問題可能是頭文件和源文件不是你項目的一部分。 如果您已經創建了一個項目,那么您可以嘗試以下操作:
我找到了答案,這只是一個設置錯誤......
在我的文件選項中,我必須擁有:
如果我右鍵單擊 -> 屬性 -> 在每個文件上構建一個文件,我必須確保選中了“調試”復選框。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.