0

Running Windows 7 64-bit (Intel i5 64bit).

I remember setting up Visual Studio 2017 Community for 32-bit.

(I assumed this would give my apps backwards compatibility and also run on 64 bit machines, maybe a bad assumption?).

In any case, to confirm, the advanced linker settings are targeting x86... as well as the build configurations targeting 32bit, x86.

My app (C++ with Boost) has been compiling and running fine.

Now I am trying to add cURL but not looking so good.

Steps Attempted to compile cURL as 32 bit:

  • c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build>vcvarsall.bat x86
  • nmake /f Makefile.vc mode=static MACHINE=x86

(also tried linking static C CRT with RTLIBCFG=static, no difference)

  • Additional Include Directories: added path to /include dir

  • Preprocessor Definitions: added CURL_STATICLIB

  • Additional Library Directories: added path to /lib
  • Additional Dependencies: added libcurl_a.lib

The cURL function in this sample linked:

CURL *curl = curl_easy_init();
if (curl) printf("curl_easy_init() succeeded!\n");
else fprintf(stderr, "Error calling curl_easy_init().\n");
return 0;

but at the very end of the compile"

fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'

VCTargets\Microsoft.CppCommon.targets(720,5): error MSB6006: "link.exe" exited with code 1112.

UPDATE: Linker Advanced Setting was not set back to x86 after trying below links, the true error is:

fatal error LNK1120: 60 unresolved externals

they all look like this but for each object file referenced:

libcurl_a.lib(easy.obj) : error LNK2019

(FYI - I did try these and build cURL as if I were targeting x64, but the functions (in the sample code) would not resolve during linking.)

Getting cURL to work with Visual Studios 2017

Getting LibCurl to work with Visual Studio 2013

P.S.
  • 384
  • 3
  • 18
  • I just added all the curl files to a new folder in an existing project, set the include directory, and compiled. Seemed like the easiest way to deal with it. – Retired Ninja Oct 13 '18 at 04:12
  • 1
    "module machine type 'x86' conflicts with target machine type 'x64'" are you sure you are compiling your project for Win32 (aka x86)? – Swordfish Oct 13 '18 at 04:12
  • 1
    @RetiredNinja I - the lazy guy I am - would have used NuGet. – Swordfish Oct 13 '18 at 04:13
  • 1
    [Does this help?](https://stackoverflow.com/questions/3563756/fatal-error-lnk1112-module-machine-type-x64-conflicts-with-target-machine-typ) – PaulMcKenzie Oct 13 '18 at 04:13
  • @swordfish: Dang...I had tried to change VS to 64 and forgot the advanced linker at 64 bit...let me re-try – P.S. Oct 13 '18 at 04:23
  • @paulmckenzie: went through that, however the 4 step (the most important?) is depreciated in that menu and could not find it....and really wanted to keep things 32 – P.S. Oct 13 '18 at 04:24
  • @Swordfish I always forget to check that for C++ things. I don't expect them to be there. Thanks for the reminder. :) – Retired Ninja Oct 13 '18 at 04:27
  • 2
    @RetiredNinja Its just like with Schroedingers Cat ... you \*have\* to look. ;) – Swordfish Oct 13 '18 at 04:32
  • @swordfish: Ok, fatal error LNK1120: 60 unresolved externals....however it built without error as a dll (but haven't run it)...now sure why it cant resolve the cURL calls built static? – P.S. Oct 13 '18 at 04:33
  • @P.S. Step 4: Project Properties -> [Tree to the left] Configuration Propertioes --> VC++ Directories --> [Right side] Include/Library Directories. Make sure you add them to all configurations you are interested in. – Swordfish Oct 13 '18 at 04:37
  • so either compile as a DLL if it actually runs or update VS to 64 bit? – P.S. Oct 13 '18 at 04:39
  • The DLL does compile and execute correctly...was really wanting static but may have to go this route.... – P.S. Oct 13 '18 at 05:24

0 Answers0