dllimport


Unresolved external symbol


I have two WIN32 DLL projects in the solution, main.dll should call a function in mgn.dll.
mgn.dll has mgn.h header file:
#ifdef MGN_EXPORTS
#define MGN_API __declspec(dllexport)
#else
#define MGN_API __declspec(dllimport)
#endif
extern "C" bool MGN_API AttachMGN(void);
and mgn.cpp source file:
#include "stdafx.h"
#include "mgn.h"
MGN_API bool AttachMGN(void)
{
...
}
main.dll calls AttachMGN function from one of the source file:
#include "stdafx.h"
#include "..\mgn\mgn.h"
bool CreateClient()
{
return ::AttachMGN();
}
mgn.dll compiles successfully. main.dll doesn't show any errors in VS text editor, I can navigate using "Go To Definition" function. However during build I get the error:
error LNK2019: unresolved external symbol __imp__AttachMGN referenced in function "bool __cdecl CreateClient(void)" (?CreateClient##AW4XZ)
Both DLLs compile into the same folder. DependencyWalker shows the function AttachMGN as exported. Main project has a dependency set to Mgn project, if that matters.
I believe that I simply have overlooked something....
Thanks in advance.
You probably just forgot to add MGN.lib to your link arguments for main.dll
Is your mgn.lib linked with the main? By the sound of it, it looks as if main cannot find the lib file to link against the DLL.

Related Links

Mangled member function name different during dllimport
how to use DllImport in metro-style app
Converting doc file to post script
How can I get a COM component which can be used on Windows phone 8 project with C#
Externs and DLL imports
Mixed native and managed code heap corruption
MarshalDirectiveException
call unmanaged C++ code from C# using pinvoke
Detecting DLL Code Splicing
WOW64 Redirection and LoadLibrary
Using C# dll in Windows phone 7
Python 2.5 Import dll AttributeError
Replacing the Import Table in PE file by standart LoadLibrary
Unresolved external symbol
Declare and <DllImport> in VB.NET have different results
how to import/export dll and use its function

Categories

HOME
shell
windows
phantom-dsl
httparty
google-cloud-platform
localization
api
checkstyle
fuelux
gdb
object
mjml
replace
seo
google-apps
crystal-reports-2013
crystal-lang
recordrtc
gource
do-while
package-managers
alpacajs
dynamic-sql
digital-signature
nim
breadth-first-search
direct3d11
syntax-highlighting
licensing
asymptotic-complexity
winexe
paperjs
comparable
testcomplete
magento-1.8
corenlp-server
recurring-events
spring-security4
contacts
nested-lists
reason
openproject
imagenet
sessionstorage
dcmtk
attributeerror
install.packages
plan-9
robomongo
spring-data-couchbase
android-testing
filehandle
jqchart
offline.js
rsa-archer-grc
branch-prediction
pocketsphinx-android
materialized-path-pattern
rocks
visual-studio-2008-sp1
greatest-n-per-group
signalr.client
gogs
angular-ui-typeahead
findfirst
jaunt-api
toran-proxy
toolkit
jdk1.7
sha512
botan
omnifaces
node-serialport
sip-server
clickbank
mt4j
mbunit
asdf
process-explorer
scmmanager
video-codecs
midlet
qtconcurrent
rmiregistry
subgraph
mapping-by-code
photolibrary
commerceserver2007
dot-emacs
ajax-polling
murmurhash
skype4java
dsl-tools
unmanagedresources
idatareader

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App