ページ 11

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

Posted: 2009年5月20日(水) 09:34
by hal
こんにちは。いつもこちらのサイトにはお世話になっています。
龍神録のプログラムを基にして、シューティングゲームを制作しているのですが、
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: 外部シンボル~ は未解決です。”というエラーについて

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

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

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

Posted: 2009年5月20日(水) 10:15
by Mist
※間違い回答だったので削除

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

Posted: 2009年5月20日(水) 19:50
by hal
すみません
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: 外部シンボル~ は未解決です。”というエラーについて

Posted: 2009年5月20日(水) 20:18
by さが
struct point_item_t * point_item と書いてありますが
もしcalc や iniファイルで struct と書いているなら削除してみてください。

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

Posted: 2009年5月20日(水) 20:25
by hal
>さがさん
ご意見ありがとうございます
calc.cpp ini.cpp内共に探してみましたが、structと書いた部分はありませんでした。

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

Posted: 2009年5月21日(木) 08:42
by hal
解決しました。
プロジェクトファイルと同じフォルダに入っているDebugを一旦削除するとエラーが出なくなりました。
回答してくださった方々ありがとうございました。