Author Topic: Build file: "no target" in DLL (compiler: GNU GCC Compiler)  (Read 4341 times)

Offline atztek

  • Single posting newcomer
  • *
  • Posts: 2
Build file: "no target" in DLL (compiler: GNU GCC Compiler)
« on: December 15, 2015, 04:44:47 pm »

 Hello,

I'm new in programming. I tried to reproduce the code, mentioned in the following link:

"Simple C++ DLL Programming Tutorial"
https://www.youtube.com/watch?v=fzO9L6tlXDI

DLL was created successfully, but exe-file was not created and I received a message:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-------------- Build: Release in DLL (compiler: GNU GCC Compiler)---------------

Target is up to date.
Nothing to be done (all items are up-to-date).

-------------- Build file: "no target" in DLL (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe   -c ..\TEST_LAUNCH_DLL\LaunchDLL.cpp -o ..\TEST_LAUNCH_DLL\LaunchDLL.o
mingw32-g++.exe  -o ..\TEST_LAUNCH_DLL\LaunchDLL.exe ..\TEST_LAUNCH_DLL\LaunchDLL.o   
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


After that I clicked "Debug" and popup widow appeared with a message:
"You must select a host application to "run" a library"


Please, explain me what to do in order to fix the problem.


Thanks!





3 files attached:

1. LaunchDLL.cpp

// ``````````````````````````````````````````````````````````````````````````````````````````````````
#include <iostream>
#include <windows.h>

using namespace std;

typedef int (*MsgFunction) (int);

HINSTANCE hinstDLL;

int main() {
   MsgFunction MsgBox(0);
   hinstDLL         = LoadLibrary("InfernoDevelopment.dll");

   if(hinstDLL != 0) {
      MsgBox        = (MsgFunction)GetProcAddress(hinstDLL,"MsgBox");
   }

   if(MsgBox == 0) {
      cout << "MsgBox is NULL" << endl;
   }

   int x            = MsgBox(5);

   if(x == 5) {
      cout << "Message Displayed!" << endl;
   }
   FreeLibrary(hinstDLL);
   return 0;
}
// ``````````````````````````````````````````````````````````````````````````````````````````````````


2. main.cpp

// ``````````````````````````````````````````````````````````````````````````````````````````````````
#include "main.h"

// a sample exported function
int DLL_EXPORT MsgBox(int x = 0) {
   MessageBox(0, "Join Us at Inferno Dev!", "DLL Message", MB_OK | MB_ICONINFORMATION);
   return x;
}

extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
    switch (fdwReason)
    {
        case DLL_PROCESS_ATTACH:
            // attach to process
            // return FALSE to fail DLL load
            break;

        case DLL_PROCESS_DETACH:
            // detach from process
            break;

        case DLL_THREAD_ATTACH:
            // attach to thread
            break;

        case DLL_THREAD_DETACH:
            // detach from thread
            break;
    }
    return TRUE; // succesful
}
// ``````````````````````````````````````````````````````````````````````````````````````````````````


3. main.h

// ``````````````````````````````````````````````````````````````````````````````````````````````````
#ifndef __MAIN_H__
#define __MAIN_H__

#include <windows.h>

/*  To use this exported function of dll, include this header
 *  in your project.
 */


#define DLL_EXPORT __declspec(dllexport)



#ifdef __cplusplus
extern "C"
{
#endif

int DLL_EXPORT MsgBox(int x);

#ifdef __cplusplus
}
#endif

#endif // __MAIN_H__
// ``````````````````````````````````````````````````````````````````````````````````````````````````









Offline atztek

  • Single posting newcomer
  • *
  • Posts: 2
Re: Build file: "no target" in DLL (compiler: GNU GCC Compiler)
« Reply #1 on: December 15, 2015, 06:14:40 pm »

I found solution for this problem, publish it only for the reference, maybe someone with same issue will find it useful.

There are two DLL-s from compiler, which are missing - need to add path to them to Windows 'PATH' environmental variable or copy them to the folder with compiled exe-file:

- libgcc_s_dw2-1.dll
- libstdc++-6.dll

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7597
    • My Best Post
Re: Build file: "no target" in DLL (compiler: GNU GCC Compiler)
« Reply #2 on: December 15, 2015, 09:36:30 pm »
FYI: This solution from the OP is likely only valid when the same compiler vendor is used.

The OP is likely using an compiler from mingw.org or one closely based on it.

OP: Original Poster

Tim S.


I found solution for this problem, publish it only for the reference, maybe someone with same issue will find it useful.

There are two DLL-s from compiler, which are missing - need to add path to them to Windows 'PATH' environmental variable or copy them to the folder with compiled exe-file:

- libgcc_s_dw2-1.dll
- libstdc++-6.dll
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org