”error LNK2001: 外部シンボル~ は未解決です。”というエラーについて

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
hal

”error LNK2001: 外部シンボル~ は未解決です。”というエラーについて

#1

投稿記事 by hal » 16年前

こんにちは。いつもこちらのサイトにはお世話になっています。
龍神録のプログラムを基にして、シューティングゲームを制作しているのですが、
GV.h内に

GLOBAL int img_item[3][3];
GLOBAL int img_point_item[3][3];
GLOBAL int point_item_t point_item[POINT_ITEM_MAX];
という配列を定義したところ、


calc.obj : error LNK2001: 外部シンボル ""struct point_item_t * point_item" (?point_item@@3PAUpoint_item_t@@A)" は未解決です。
ini.obj : error LNK2001: 外部シンボル ""struct point_item_t * point_item" (?point_item@@3PAUpoint_item_t@@A)" は未解決です。
out.obj : error LNK2001: 外部シンボル ""struct point_item_t * point_item" (?point_item@@3PAUpoint_item_t@@A)" は未解決です。
graph.obj : error LNK2001: 外部シンボル ""struct point_item_t * point_item" (?point_item@@3PAUpoint_item_t@@A)" は未解決です。
load.obj : error LNK2001: 外部シンボル ""int (* img_item)[3]" (?img_item@@3PAY02HA)" は未解決です。
graph.obj : error LNK2019: 未解決の外部シンボル "int (* img_item)[3]" (?img_item@@3PAY02HA) が関数 "void __cdecl graph_point_item(void)" (?graph_point_item@@YAXXZ) で参照されました。
load.obj : error LNK2001: 外部シンボル ""int (* img_point_item)[3]" (?img_point_item@@3PAY02HA)" は未解決です。
D:\stg\project\pla.pla\Debug\PlaPla.exe : fatal error LNK1120: 外部参照 3 が未解決です。


というエラーが出るようになりました。
何度も解決を試みたのですが、他の配列(GLOBAL enemy_t enemy[ENEMY_MAX]; など)と何が違うのか、何が原因なのかさっぱり分かりません。
どなたか分かる方がおられましたら、ご教授お願いします。

御津凪

Re:”error LNK2001: 外部シンボル~ は未解決です。”というエラーについて

#2

投稿記事 by 御津凪 » 16年前

「外部シンボル **** は未解決です。」
という類のエラーは、 **** に書かれているものが定義されていない(or 実体がない)というものです。
上記の場合だと、ちょうど追加した3つの変数の実体がいないのが原因です。

あと、
GLOBAL int point_item_t point_item[POINT_ITEM_MAX];
の、"int"は不要だと思います。
(これが原因?)


hal

Re:”error LNK2001: 外部シンボル~ は未解決です。”というエラーについて

#4

投稿記事 by hal » 16年前

すみません
intは書き間違いで
GLOBAL point_item_t point_item[POINT_ITEM_MAX];
でした。

御津凪さん、アドバイスありがとうございました。
アドバイスを参考に再度調べてみたところ、
原因の一つは、画像をロードする為の配列img_item[3][3]、img_point_item[3][3]の長さと
格納する画像の数が合っていなかったことだったようです。
img_item[3][2]、img_point_item[2][2]とすると

load.obj : error LNK2001: 外部シンボル ""int (* img_item)[3]" (?img_item@@3PAY02HA)" は未解決です。

のエラーは消えました

しかし未だ7つのエラーが残った状態でまた解決できていません

さが

Re:”error LNK2001: 外部シンボル~ は未解決です。”というエラーについて

#5

投稿記事 by さが » 16年前

struct point_item_t * point_item と書いてありますが
もしcalc や iniファイルで struct と書いているなら削除してみてください。

hal

Re:”error LNK2001: 外部シンボル~ は未解決です。”というエラーについて

#6

投稿記事 by hal » 16年前

>さがさん
ご意見ありがとうございます
calc.cpp ini.cpp内共に探してみましたが、structと書いた部分はありませんでした。

hal

Re:”error LNK2001: 外部シンボル~ は未解決です。”というエラーについて

#7

投稿記事 by hal » 16年前

解決しました。
プロジェクトファイルと同じフォルダに入っているDebugを一旦削除するとエラーが出なくなりました。
回答してくださった方々ありがとうございました。

閉鎖

“C言語何でも質問掲示板” へ戻る