0

Running this code in Code::Blocks 20.03, got a #pragma comment(lib, "comctl32.lib") in my header, no joy. I know I need to add it to the linker, as done here, but WHERE is the comctl32.lib file?

Edit: fixed the Pragma, but the problem still happens.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • 1
    These are standard windows libraries in the windows api. For me the file exists here: `C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um` in the x64, x86, arm and arm64 folders. – drescherjm Dec 29 '20 at 19:52
  • Followed that path, `10.0.10240.0\`, no `um` folder, only `ucrt`. In there are the processors, with files `libucrt.lib`, `'libucrtd.lib', `ucrt.lib`, and `ucrtd.lib`, across each one. – Kelson Rumak Dec 29 '20 at 20:02
  • I am have these installed because I use Visual Studio 2019 community. I assume you need to download and install the windows SDK or maybe there is some mingw setup. I don't really use that. – drescherjm Dec 29 '20 at 20:04
  • 2
    There are a lot of links here. Could you make the question self-contained so it's useful for other/future visitors, please? – Asteroids With Wings Dec 29 '20 at 20:15
  • 1
    CodeBlocks implies you're using MinGW rather than MSVC? Then those `#pragma`s are of no use, instead you need to change the linker settings. Also you need `lib??.a`, not `??.lib`. The `-lcomdlg32` flag should just work out of the box. At least it does for me on MSYS2. – HolyBlackCat Dec 29 '20 at 20:30
  • @HolyBlackCat You beautiful genius, that solved it! Well, it compiles now, time to make it work. – Kelson Rumak Dec 29 '20 at 20:49

1 Answers1

3

Your #pragma is specifying the wrong filename. GetOpenFileName() is implemented in comdlg32.dll, not in comctl32.dll. The correct lib filename you need to use is comdlg32.lib. This is stated as much in the function's documentation:

image

Once you correct that, if you still get the same error, then you likely don't have the Windows SDK installed for your compiler, or you don't have your compiler's search paths setup properly to find the SDK files.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770