LNK2019: unresolved external symbol __imp__lcb_create referenced in function _main

Hi, I’m new to couchbase, and trying to build a simple query tool using C SDK. I’m using community couchbase server version 5.1.1 on my laptop (windows 10), Windows version of C SDK, and Visual Studio 2019.

I included couchbase header and lib/bin(do see libcouchbase.dll in the bin directory) paths in Visual Studio. With that I was able to use header file. But getting the following link time error:

1>------ Rebuild All started: Project: couchbase-query, Configuration: Debug Win32 ------
1>couchbase-query.cpp
1>couchbase-query.obj : error LNK2019: unresolved external symbol __imp__lcb_create referenced in function _main
1>C:\Users\sbtee\source\repos\ConsoleApplication1\Debug\couchbase-query.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

============ Here is my code ============

#include <iostream>
#include <libcouchbase/couchbase.h>

int main()
{
	lcb_error_t err;
	lcb_t instance;
	struct lcb_create_st create_options = { 0 };
	lcb_CMDSTORE scmd = { 0 };
	lcb_CMDGET gcmd = { 0 };

	create_options.version = 3;
	create_options.v.v3.connstr = "http://127.0.0.1:8091";
	create_options.v.v3.username = "Administrator";
	create_options.v.v3.passwd = ".....";

	err = lcb_create(&instance, &create_options);
}

Thanks

It seems like you didn’t link libcouchbase during compilation, so it cannot resolve symbols.

You can find how to link third-party libraries on microsoft documentation site:
https://docs.microsoft.com/en-us/cpp/build/reference/dot-lib-files-as-linker-input?view=vs-2019

Thanks Sergey!

I was able to build and run the command by do adding the the following:

code: #pragma comment(lib, “libcouchbase.lib”)

Visual Studio: Properties->Configuration Properties->Linker->General->Addotional Library Directories: <library path to - libcouchbase.lib>

Resolve Runtime issue - Add libcrouchbase.dll path:
Properties->Configuration Properties->Debugging->Environment <PATH=%PATH%;<.dll path>