c++ - Unresolved External Symbols in complex library dependent project using WINAPI -



c++ - Unresolved External Symbols in complex library dependent project using WINAPI -

having searched days decided post question here , hope has ultimate thought or advice.

i wrote winapi wrapping mechanism consisting of windowmanager , winapiwindow class. latter uses famous "first winapi window" functionality known tutorials in more structured manner, hwnd , hinstance. remarks: macro "_ windows _" (without spaces tool makes bold otherwise ) macro defined in 1 of headers determine, wether compilation environment supports win32 , winapi.

#if defined(_ _windows_ _) lresult callback gdefaultwndprocfwd(hwnd hwnd, uint msg, wparam wparam, lparam lparam); #pragma part winapiwindow class winapiwindow : public windowbase { friend class windowmanager; public: virtual ~winapiwindow(); result show(); inline hwnd handle() const; lresult callback wndproc(hwnd hwnd, uint msg, wparam wparam, lparam lparam); private: winapiwindow(__in const hinstance hinstance, __in const rect& bounds, __in const string& title = "", __in const int flags = wdf_default); hresult createwindowclass(__in const hinstance hinstance, __in const string& clsname); tint16 _wndstate; hwnd _hwnd; }; typedef winapiwindow window; #pragma endregion #elif

the mechanism located in static library called "shirabeplatformfeaturelayer.lib". static library uses classes , code custom static lib called "shicore.lib" not utilize platform dependent code.

my actual application project (x64!) imports both additional depenencies using windowmanager.

although both library projects compile fine , without errors, compiling application project leads next error messages.

error 43 error lnk2019: unresolved external symbol "public: struct hwnd__ * __cdecl shirabeplatformfeaturelayer::winapiwindow::handle(void)const " (?handle@winapiwindow@shirabeplatformfeaturelayer@@qebapeauhwnd__@@xz) referenced in function wwinmain c:\users\dev.dev-pc\documents\workspaces\shirabeengine\shirabedevelopment\win32testproject\main.obj win32testproject error 45 error lnk2019: unresolved external symbol "__int64 __cdecl shirabeplatformfeaturelayer::gdefaultwndprocfwd(struct hwnd__ *,unsigned int,unsigned __int64,__int64)" (?gdefaultwndprocfwd@shirabeplatformfeaturelayer@@ya_jpeauhwnd__@@i_k_j@z) referenced in function "private: long __cdecl shirabeplatformfeaturelayer::winapiwindow::createwindowclass(struct hinstance__ * const,class shirabecore::string const &)" (?createwindowclass@winapiwindow@shirabeplatformfeaturelayer@@aeaajqeauhinstance__@@aebvstring@shirabecore@@@z) c:\users\dev.dev-pc\documents\workspaces\shirabeengine\shirabedevelopment\win32testproject\shirabeplatformfeaturelayer.lib(window.obj) win32testproject error 44 error lnk2001: unresolved external symbol "public: struct hwnd__ * __cdecl shirabeplatformfeaturelayer::winapiwindow::handle(void)const " (?handle@winapiwindow@shirabeplatformfeaturelayer@@qebapeauhwnd__@@xz) c:\users\dev.dev-pc\documents\workspaces\shirabeengine\shirabedevelopment\win32testproject\shirabeplatformfeaturelayer.lib(windowmanager.obj) win32testproject error 46 error lnk1120: 2 unresolved externals c:\users\dev.dev-pc\documents\workspaces\shirabeengine\shirabedevelopment\debug\win32testproject.exe win32testproject

i checked, whether methods declared , defined properly. included , imported libs.

#if defined(_ _windows_ _) #pragma comment(lib, "user32.lib") #pragma comment(lib, "kernel32.lib") #pragma comment(lib, "gdi32.lib") #include <windows.h> #endif

in add-on registered 3 libs above additional dependencies , lib-directories $(vc_librarypath_x64) , $(windowssdk_librarypath_x64).

my first thoughts after having analyzed bit is, methods or functions utilize winapi classes , structs not linked import library "shirabeplatformfeaturelayer.lib". having registered them above 3 libs additional dependencies equal library paths above , /verbose:lib shows me libraries appended not "x64\gdi32.lib" message "gdi32.dll". likewise other two.

doing /verbose:lib in application project shows me actual relative paths "~.lib" , not "~.dll".

what can cause methods not beingness linked/included/important when utilize winapi functionality? general build design many .libs problem? else have idea?

here entire affected code ( imho ): http://pastebin.com/f7mabbwm

if farther info required, please tell me.

edit: i've continued searching , came "project project" dependencies in new msbuild system. although appeared same problem, isn't since dependency of "shirabeplatformfeaturelayer.lib" import libs kernel32, gdi32 , user32 causes problem, when beingness consumed win32testproject using shirabeplatformfeaturelayer.lib code.

unfortunately wasn't able solve problem yet various advice given est. 10 different articles on topic. :/

edit: consulting rodrigo s remarks able rid of handle() unresolved symbol. sec gdefaultwndprocfwd seems logic/design error.

once managed 10 reputation i'll attach image of relation between windowmanager, winapiwindow , gdefaultwndprocfwd! said here textual description:

1) creating window implies creating windowclassex construction refers gdefaultwndprocfwd using forwards declaration in window.h.

2) when window created , shown method should called, consults windowmanager::get(key : hwnd) : windowbase*;

3) if found, function invokes wndproc on window pointer , leaves handling specified implementation of wndproc.

the gdefaultwndprocfwd declared , defined in windowmanager.h/.cpp.

the design flaw becomes more , more obvious, i'm thinking solution! see pastebin link actual code!

thank much help in advance.

sincerely, marc

you have 2 unresolved external symbols:

hwnd shirabeplatformfeaturelayer::winapiwindow::handle(void) const lresult shirabeplatformfeaturelayer::gdefaultwndprocfwd(hwnd,uint,wparam,lparam)

the first 1 due handle() beingness inline. defined in cpp file (or forgot it?) , since inline, definition not exported. instead expected available every compilation unit needs it. in other words, inline functions should defined in same header file declaration.

the sec 1 trickier without seeing code. i'd bet forgot write defintion of gdefaultwndprocfwd(). or maybe wrote in different namespace, or different parameters.

note static libraries not linked, unresolved symbol errors such yours, never happen when building library, when defect in library itself. linker errors happen when linking final executable.

update: ok, said tricky... re-reading code noticed offending function declared twice, , defined once. not problem, @ 2 declarations together:

lresult callback gdefaultwndprocfwd(hwnd hwnd, uint msg, lparam lparam, wparam wparam); lresult callback gdefaultwndprocfwd(hwnd hwnd, uint msg, wparam wparam, lparam lparam);

and definition is:

lresult callback gdefaultwndprocfwd(hwnd hwnd, uint msg, lparam lparam, wparam wparam)

do see difference? wparam , lparam swapped!!!

c++ c winapi dll static-libraries

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -