3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visual Studio 2019 の C++/CLI プロジェクトでリンクのエラーが発生する。

Last updated at Posted at 2020-01-30

背景

以前 Visual Studio 2012 で作成した 32bit の VC プロジェクトを Visual Studio 2019 で 64bit 対応したときに、久しぶりに触って色々忘れていたのでメモ。

概要

プラットフォームを「x64」に切り替えてビルドした所、リンクで下記のようなエラーが発生。

error LNK2028: 未解決のトークン (0A00000C) "extern "C" int cdecl SetForegroundWindow(struct HWND *)" (?SetForegroundWindow@@$$J0YAHPEAUHWND__@@@Z) が関数 "public: static bool __clrcall HogeApp::ActivateWindow(class System::String ^)" (?ActivateWindow@HogeApp@@$$FSM_NPE$AAVString@System@@@Z) で参照されました。

解決方法

リンクのエラーなので、作成したプログラムから SetForegroundWindow 関数があるライブラリにパスが通っていないため起こる。

SetForegroundWindow 関数をググってみると、user32.lib にあることがわかるので、プロジェクトのプロパティを開き、 [構成プロパティ]-[リンカ]-[入力] に user32.lib を追加する。

HogeAppProp001.png

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?