pdcurses linkage using Visual Studio 2010

北城以北 提交于 2019-12-21 05:31:25

问题


This is doing my nut in. I'm just trying to include pdcurses (i.e. ncurses for windows) into a test program. Linkage though is failing.

Using Visual Studio 2010.

I'm fully aware of setting up the correct link additional libraries path and to list the libraries themselves. No joy.

I've tried the various pre-builts on the pdcurses website. No such luck.

I of course resorted to building from source. Using nmake from the Visual Studio command prompt as prescribed. Built ok. Nada on link.

What am I missing. It's maybe just too late on Friday...

Output below:

1>------ Build started: Project: test, Configuration: Debug x64 ------
1>Build started 14/12/2012 16:24:32.
1>InitializeBuildStatus:
1>  Touching "x64\Debug\test.unsuccessfulbuild".
1>ClCompile:
1>  main.c
1>C:\dep\pdcurses\curses.h(160): warning C4005: 'MOUSE_MOVED' : macro redefinition
1>          C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\wincon.h(101) : see previous definition of 'MOUSE_MOVED'
1>main.c(73): warning C4133: 'function' : incompatible types - from 'unsigned short [20]' to 'const char *'
1>ManifestResourceCompile:
1>  All outputs are up-to-date.
1>main.obj : error LNK2019: unresolved external symbol endwin referenced in function main
1>main.obj : error LNK2019: unresolved external symbol wgetch referenced in function main
1>main.obj : error LNK2001: unresolved external symbol __imp_stdscr
1>main.obj : error LNK2019: unresolved external symbol refresh referenced in function main
1>main.obj : error LNK2019: unresolved external symbol printw referenced in function main
1>main.obj : error LNK2019: unresolved external symbol initscr referenced in function main
1>C:\proj\test.exe : fatal error LNK1120: 6 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.47

回答1:


Ok. I feel rather stupid. Here is the solution for posterity...

The distributed pdcurses binaries are 32bit. I was trying to build for 64bit.

Fundamentally, I forgot the first rule of linkage: don't mix and match architectures.

More specifically, when attempting to then build from source:

1) beware of starting the wrong Visual Studio command prompt. The default one from the Tools menu is the x86 one. If you just try and run cl.exe you'll find this out.

Instead, run the prompt from the start menu: Microsoft Visual Studio 2010->Visual Studio Tools->Visual Studio x64 Win64 Command Prompt (2010)

Invoke the build then by cd'ing to pdcurses directory/win32a and typing:

nmake -f vcwin32.mak DLL=pdcurses.dll

Also, 2) before you compile pdcurse change line 111 of the pdcurses Windows makefile (vcwin32.mak):

cvtres /MACHINE:X64 /NOLOGO /OUT:pdcurses.obj pdcurses.res

(NOTE: i.e. X64 architecture!)

Everything is now consistent. The pdcurses library will build. And it will link with my test app which (as the original output shows) I am building on x64.



来源:https://stackoverflow.com/questions/13883130/pdcurses-linkage-using-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!