プロが教える店舗&オフィスのセキュリティ対策術

Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5 SP1
----------------------------------------------------------------
新しいプリジェクト→Win32 コンソール アプリケーション(ソリューションのディレクトリを作成 チェック外す)→Windows アプリケーション(空のプロジェクト チェック外す)
----------------------------------------------------------------
 プログラム

 mymain.cpp
#include "myhelper.h"
#include "mymain.h"

//自キャラのデータ
Point2D g_jikipos = {40, 400};//自キャラの座標

//画像ハンドル
int g_jikiimage[11];

//色々なファイルの読み込み
int LoadFiles(){
//画像ファイル読み込み
if(LoadDivGraph("media\\player01.bmp",
11,11,1,64,64,g_jikiimage) == -1) return -1;

return 1;
}


 mymain.h
//他から呼び出させるMyMainの関数
void MyMain();
int LoadFiles();


 myhelper.h(サンプルなので打ちミスはない)
#include "DxLib.h"
#include <limits.h>
#include <math.h>

//構造体宣言
//座標またはベクトルを記録する構造体
struct Vector{
float x,y;
};
typedef Vector Point2D;
//線を記録する構造体
struct Line2D{
Point2D startpos, endpos;
float katamuki;//傾きをラジアン値で記録
Vector speed;//移動している場合は速度をセット
};
//球体を記録する構造体
struct Ball2D{
Point2D position;
float hankei;//半径
};
//四角形を記録する構造体
struct Rect2D{
Point2D lefttop;
Point2D rightbottom;
float width;
float height;
};


//ライブラリ関数
Point2D PosInView(Point2D in);
int XInView(float inx);
int YInView(float iny);
void ScrollToLeft(float jikiposx);
void ScrollToRight(float jikiposx);
void ScrollToUp(float jikiposy);
void ScrollToDown(float jikiposy);
void DrawLineInView(float x1, float y1, float x2, float y2, int Color, int Thickness);
void DrawCircleInView(float x, float y, float r, int Color, int FillFlag);
void DrawAnimation(float x, float y, double ExtRate, double Angle,int TurnFlag,
int *imgarray, int allframe, float fps);
//ベクトル関数
Vector CreateVector(Vector in, float veclen);
Vector AddVector(Vector v1, Vector v2);
Vector SubVector(Vector v1, Vector v2);
Vector AddVectorInFrameTime(Vector pos, Vector speed);
Vector AddVectorInFrameTime2(Vector pos, Vector speed, Vector accel);
Vector Normalize(Vector in);
Vector RotateVector(Vector in, float radian);
float VectorLengthSquare(Vector in);
float DotProduct(Vector v1, Vector v2);
float CrossProduct(Vector v1, Vector v2);
void SetLine2DKatamuki(Line2D *in);
void DrawLine2D(Line2D in, int Color, int Thickness);
void DrawBall2D(Ball2D in, int Color, int Fill);
//当たり判定関数
bool HitTestLineAndBall(Line2D linein, Ball2D ballin);
bool IsPointAtLineFace(Line2D linein, Point2D ptin);
bool HitTestLineAndLine(Line2D line1, Line2D line2);
bool HitTestBallAndBall(Ball2D a, Ball2D b);
bool HitTestPointAndBox(Rect2D rect, Point2D pt);
//タイマー関数
void SetSimpleTimer(int idx, int time);
int GetPassedTime(int idx);


//グローバル変数
extern float g_frametime;
extern Rect2D g_framerect;//画面領域(当たり判定)
extern Point2D g_current_field_pos;//現在の左上座標
extern Rect2D g_stagesize;//ステージサイズ

//定数宣言
const float ZEROVALUE = 1e-10f;
const float PIE = 3.1415926f;
const int SCROLL_LIMIT = 200;
----------------------------------------------------------------
 エラー内容
1>myhelper.obj : error LNK2019: 未解決の外部シンボル "void __cdecl MyMain(void)" (?MyMain@@YAXXZ) が関数 _WinMain@16 で参照されました
1>C:\Documents and Settings\Owner\My Documents\Visual Studio 2008\Projects\my\Debug\my.exe : fatal error LNK1120: 外部参照 1 が未解決です
1>my - エラー 2、警告 0
ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ
----------------------------------------------------------------
画像を貼り付けときます
(見えにくい場合→http://www.dotup.org/uploda/www.dotup.org154142. …
初心者なのでわかりやすくお願いします

A 回答 (3件)

ファイル構成から推測するに


mymain.cpp というファイルに
void MyMain(void) {
// ここに処理を書く
}
という関数が必要なようです。

この回答への補足

書き足りなかったところを・・・
----------------------------------------------------------------
 -プロパティー -
構成(アクティブ) 文字セット→マルチバイト、コード生成→マルチデバック(/MTd)

構成(Relesae) 文字セット→マルチバイト、コード生成→マルチスレッド(/MT)
----------------------------------------------------------------
 -ツール→オプション-
VC++ディレクトリ。インクルードファイル
C:\Documents and Settings\Owner\デスクトップ\ゲーム製作\kaihatsu\DxLib_VC\プロジェクトに追加すべきファイル_VC用
を追加。

続いて、ライブラリファイル。
:\Documents and Settings\Owner\デスクトップ\ゲーム製作\kaihatsu\DxLib_VC\プロジェクトに追加すべきファイル_VC用
を追加
----------------------------------------------------------------
myファイル中にちゃんと入ってます。

マイドキュメント\Visual Studio 2008\Projects\my\

myhelper.h
mymain.h
mymain.cpp
myhelper.cpp

media\player01.bmp
----------------------------------------------------------------
DXライブラリ、ソースコード、画像は
http://www.rutles.net/download/217/index.html
ここからDLしてきたものです

本どおりに設定しているので間違ってるとは思えないんですけどね・・・

補足日時:2009/09/18 21:00
    • good
    • 3
この回答へのお礼

とりあえず、追加したところエラーはおきませんでした。

ですが、何も映らない・・・
ん~後はこれに何かつけくわえればいいのかな・・・

アドバイスありがとうございます。

お礼日時:2009/09/18 21:07

>未解決の外部シンボル



このリンクエラーは、当該の関数なり変数なりを
「宣言はしているが定義していない」というときに起きます。

当該の関数や変数を定義してください。

この回答への補足

ちょっとここに書くのもなんだけど・・・


やっと原因わかりました!

php504さんの
>void MyMain(){
が見事ビンゴしておりました。

まさか次のページじゃないと動かせないとは・・・

皆さんお答え頂ありがとうございます!

補足日時:2009/09/18 22:00
    • good
    • 3
この回答へのお礼

なるほど・・・ちょっと見てきます。
まだ初心者なので時間かかるかもですが・・・

アドバイスありがとうございます

お礼日時:2009/09/18 20:49

//他から呼び出させるMyMainの関数


void MyMain();

となっていますが、その本体が無いですね
(これは宣言なので、「こういう関数があるよ」って教えているだけです)
    • good
    • 3
この回答へのお礼

お答えありがとうございます。

本体とは、ファイルのことなのか。
確かにないですね・・・

ん~、まだいまいちわかりません(。´Д⊂)

お礼日時:2009/09/18 20:46

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!