Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Hi,
I am trying to build a small plugin demo as a shared library using cmake. I get the following link error in the build process. I have used wxWidgets compiled from source (downloaded from github) using Visual Studio 2017 on a windows 10 machine. The "minimal" sample application and other demo application compile fine.
Thanks in advance for any help in resolving this issue.
Any help on this topic will be highly appreciated.
I am attaching the workspace which I use for reference. The same code works fine in gcc version 7.1. I am using VS 2017 compiler on a Windows 10 machine.
warning C4275: non dll-interface class 'wxObject' used as base for dll-interface class 'wxNonGuiPluginBase'
I'm pretty sure this is the key, but i have no idea what to do about it, especially if it works with GCC.
Did you use the same CRT settings (/MT vs /MD etc.) in your project as in wxWidgets?
As this problem is not really wxWidgets specific, i would also suggest to google for "warning C4275". I found several posts, although i didn't see anything that looked like a solution for your project.
Hi,
So you do have the same problem when you try to compile "minimal" sample provided with the library?
Did you try to open the solutiuon inside the IDE right agter you compile the library?
No. The wxwidgets is build with dynamic configuration and the code which I am building is also a dll. So there is no problem with this. The problem seems to be the right way to export and import the symbols in the dll.
Finally I was able to resolve this issue. Please find the comment in line 3 of the code below. Once I remove this include I am able to create the dll. I do not understand why it is? Maybe someone can help me in understand this better.
Further I also had to provide the -DWXMAKING_NGUI option in the cmake file while compiling the DLL.
#pragma once
#if defined(__WXMSW__)
#include <wx/dlimpexp.h> // This include causes a link error. I do not know why?
#ifdef WXMAKINGDLL_NGUI
# define WXDLLIMPEXP_NGUI WXEXPORT
# define WXDLLIMPEXP_DATA_NGUI(type) WXEXPORT type
# if defined(HAVE_VISIBILITY)
# define WXDLLIMPEXP_INLINE_NGUI WXEXPORT
# else
# define WXDLLIMPEXP_INLINE_NGUI
# endif
#elif defined(WXUSINGDLL_NGUI)
# define WXDLLIMPEXP_NGUI WXIMPORT
# define WXDLLIMPEXP_DATA_NGUI(type) WXIMPORT type
# if defined(HAVE_VISIBILITY)
# define WXDLLIMPEXP_INLINE_NGUI WXIMPORT
# else
# define WXDLLIMPEXP_INLINE_NGUI
# endif
#else
# define WXDLLIMPEXP_NGUI
# define WXDLLIMPEXP_DATA_NGUI(type) type
# define WXDLLIMPEXP_INLINE_NGUI
#endif
#endif
/*
#ifndef _WX_NONGUIPLUGIN_DEF_H_
#define _WX_NONGUIPLUGIN_DEF_H_
#if defined(WXMAKINGLIB_NGUI)
#define WXDLLIMPEXP_NGUI
#elif defined(WXMAKINGDLL_NGUI)
#define WXDLLIMPEXP_NGUI WXEXPORT
#elif defined(WXUSINGDLL_NGUI)
#define WXDLLIMPEXP_NGUI WXIMPORT
#else // not making nor using DLL
#define WXDLLIMPEXP_NGUI
#endif
// GCC warns about using __declspec on forward declarations
// while MSVC complains about forward declarations without
// __declspec for the classes later declared with it. To hide this
// difference a separate macro for forward declarations is defined:
#if defined(HAVE_VISIBILITY) || (defined(__WINDOWS__) && defined(__GNUC__))
#define WXDLLIMPEXP_FWD_NGUI
#else
#define WXDLLIMPEXP_FWD_NGUI WXDLLIMPEXP_NGUI
#endif
#endif
*/
Hi,
I think you might want to post to wx-dev.
You will need to attach the Cmake project file, mention you are creating a plugin dll and what did you do to fix the problem.
It is possible that the author of CMake for wxWidgets will be able to help.
Also, are you sure you are compiling against the DLL setup?