简体   繁体   English

如何使用C ++编译项目,以便在硬盘上创建项目的.dll文件,以便以后将其与其他程序一起使用?

[英]How can I compile my project in C++ so it will create on my hard disk a .dll file of my project to use it later with another program?

This is the main code: 这是主要代码:

// DSPlayer.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "DSPlayer.h"
#include "resource.h"
#include "PlayerClass.h"


/********* GLOBAL VARIABLES **********/
HINSTANCE g_hInst;
HWND g_hDialogWindow;

// pointer to my PlayerClass obejct
PlayerClass *g_PlayerObject = NULL;



/******** FUNCTION DECLARATIONS ******/
BOOL CALLBACK DlgDSPlayerProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);




int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
    MSG msg;

    HICON iconLarge = NULL;

    InitCommonControls();

    g_hInst = hInstance;

    g_hDialogWindow = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DLGDSPLAYER), NULL, (DLGPROC)DlgDSPlayerProc);

    // this will set the icon for my player
    iconLarge = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICONLARGE));

    if (iconLarge)
    {
        SendMessage(g_hDialogWindow, WM_SETICON, ICON_BIG, (LPARAM)iconLarge);
    }


    // Initialize the COM library
    CoInitialize(NULL);


    if (!g_hDialogWindow)
    {
        MessageBox(NULL, "Dialog creation failed! Aborting..", "Error", MB_OK);
        return -1;
    }

    ShowWindow(g_hDialogWindow, nCmdShow);
    UpdateWindow(g_hDialogWindow);

    if (g_PlayerObject == NULL)
    {
        // create the player object
        g_PlayerObject = new PlayerClass();

        if (g_PlayerObject)
        {
            g_PlayerObject->Initialise(g_hDialogWindow);
        }
        else
        {
            MessageBox(NULL, "Error creating player object", "Error", MB_OK);
            return -1;
        }
    }

    // standard message loop
    while (GetMessage(&msg, NULL, 0, 0))
    {
        if (!IsDialogMessage(g_hDialogWindow, &msg))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }


    return msg.wParam;
}



BOOL CALLBACK DlgDSPlayerProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    bool handled = false;

    switch (message)
    {
        case WM_INITDIALOG:
                return TRUE;

        case WM_COMMAND:
            switch ( LOWORD(wParam))
            {
                case IDC_OPENFILE:
                    handled = true;
                    ///SetWindowText(GetDlgItem(hDlg, IDC_NOWPLAYING), "You selected Play File..");
                    g_PlayerObject->OpenFileDialog();
                    break;

                case IDC_PLAYPAUSE:
                    handled = true;
                    //SetWindowText(GetDlgItem(hDlg, IDC_NOWPLAYING), "You selected Pause");
                    g_PlayerObject->DoPlayPause();
                    break;

                case IDC_STOP:
                    handled = true;
                    //SetWindowText(GetDlgItem(hDlg, IDC_NOWPLAYING), "You selected Stop");
                    g_PlayerObject->DoStop();
                    break;

                case IDC_EXIT:
                    handled = true;
                    free(g_PlayerObject);
                    EndDialog(hDlg, LOWORD(wParam));
                    PostQuitMessage(0);
                    break;
                    //handled = true;
            }

        case WM_TIMER:
            g_PlayerObject->DoTimerStuff();
            break;

        case WM_CLOSE:
            //MessageBox(NULL, "got close", "info", MB_OK);
            PostQuitMessage(0);
            break;

        case WM_GRAPHNOTIFY:
            handled = true;
            g_PlayerObject->EventReceiver();
            break;




/*      case WM_CLOSE:
            CleanUp(hDlg);
            handled = true;
            EndDialog(hDlg, LOWORD(wParam));
            break;
*/
    }

    return handled;

}

It's not my project. 这不是我的项目。

Now I went to the project properties and under General>Target Extension its: .dll And under General>Configuration Type> its: Dynamic Library (.dll) 现在,我转到项目属性,然后在General> Target Extension下:.dll在General> Configuration Type>下:动态库(.dll)

But when I'm doing doing to my project Build>Build Solution I can't find any .dll files the the Debug directory. 但是,当我在执行我的项目Build> Build Solution时,在Debug目录中找不到任何.dll文件。

I'm using Visual Studio C++ Express 2010. 我正在使用Visual Studio C++ Express 2010。

What am I missing here? 我在这里想念什么?

OutPut Results: 输出结果:

>------ Build started: Project: DSPlayer, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(298,5): warning MSB8004: Intermediate Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Intermediate Directory.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(299,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(D:\DSPlayer\DSPlayer\.\Debug\DSPlayer.dll) does not match the Linker's OutputFile property value (D:\DSPlayer\DSPlayer\Debug\DSPlayer.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.dll) does not match the Linker's OutputFile property value (.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>  DSPlayer.vcxproj -> D:\DSPlayer\DSPlayer\.\Debug\DSPlayer.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

在此处输入图片说明

This are the two warnings: 这是两个警告:

1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(D:\DSPlayer\DSPlayer\.\Debug\DSPlayer.dll) does not match the Linker's OutputFile property value (D:\DSPlayer\DSPlayer\Debug\DSPlayer.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.dll) does not match the Linker's OutputFile property value (.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).

How and where do i have to fix this warnings ? 我必须如何以及在何处修复此警告? can someone upload here a screenshot to show me how and where to do it ? 有人可以在这里上传屏幕截图,向我展示如何以及在哪里做吗?

在输出目录和中间目录中写入。\\ Debug,然后单击“清理并生成”,即使发生此警告,它也会生成.exe文件

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

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