opencv issue with vs 2013 C++ - c++

I am using opencv 2.4.8 with visual studio 2013. I have been trying to get my application to run. I know for sure the code works, but I am having linker issues I believe...
here is the error I get:
Error 1 error LNK2019: unresolved external symbol _cvCreateImage referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 2 error LNK2019: unresolved external symbol _cvInRangeS referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 3 error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl cv::format(char const *,...)" (?format#cv##YA?AV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PBDZZ) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 4 error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree#cv##YAXPAX#Z) referenced in function "public: __thiscall cv::Mat::~Mat(void)" (??1Mat#cv##QAE#XZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 5 error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray#cv##QAE#ABVMat#1##Z) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 6 error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > const &)" (??0_InputArray#cv##QAE#ABV?$vector#VMat#cv##V?$allocator#VMat#cv###std###std###Z) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 7 error LNK2001: unresolved external symbol "public: virtual class cv::Mat __thiscall cv::_InputArray::getMat(int)const " (?getMat#_InputArray#cv##UBE?AVMat#2#H#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 8 error LNK2001: unresolved external symbol "public: virtual void __thiscall cv::_InputArray::getMatVector(class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &)const " (?getMatVector#_InputArray#cv##UBEXAAV?$vector#VMat#cv##V?$allocator#VMat#cv###std###std###Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 9 error LNK2001: unresolved external symbol "public: virtual class cv::GlBuffer __thiscall cv::_InputArray::getGlBuffer(void)const " (?getGlBuffer#_InputArray#cv##UBE?AVGlBuffer#2#XZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 10 error LNK2001: unresolved external symbol "public: virtual class cv::GlTexture __thiscall cv::_InputArray::getGlTexture(void)const " (?getGlTexture#_InputArray#cv##UBE?AVGlTexture#2#XZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 11 error LNK2001: unresolved external symbol "public: virtual class cv::gpu::GpuMat __thiscall cv::_InputArray::getGpuMat(void)const " (?getGpuMat#_InputArray#cv##UBE?AVGpuMat#gpu#2#XZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 12 error LNK2001: unresolved external symbol "public: virtual int __thiscall cv::_InputArray::kind(void)const " (?kind#_InputArray#cv##UBEHXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 13 error LNK2001: unresolved external symbol "public: virtual class cv::Size_<int> __thiscall cv::_InputArray::size(int)const " (?size#_InputArray#cv##UBE?AV?$Size_#H#2#H#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 14 error LNK2001: unresolved external symbol "public: virtual unsigned int __thiscall cv::_InputArray::total(int)const " (?total#_InputArray#cv##UBEIH#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 15 error LNK2001: unresolved external symbol "public: virtual int __thiscall cv::_InputArray::type(int)const " (?type#_InputArray#cv##UBEHH#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 16 error LNK2001: unresolved external symbol "public: virtual int __thiscall cv::_InputArray::depth(int)const " (?depth#_InputArray#cv##UBEHH#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 17 error LNK2001: unresolved external symbol "public: virtual int __thiscall cv::_InputArray::channels(int)const " (?channels#_InputArray#cv##UBEHH#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 18 error LNK2001: unresolved external symbol "public: virtual bool __thiscall cv::_InputArray::empty(void)const " (?empty#_InputArray#cv##UBE_NXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 19 error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate#Mat#cv##QAEXXZ) referenced in function "public: void __thiscall cv::Mat::release(void)" (?release#Mat#cv##QAEXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 20 error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::copySize(class cv::Mat const &)" (?copySize#Mat#cv##QAEXABV12##Z) referenced in function "public: __thiscall cv::Mat::Mat(class cv::Mat const &)" (??0Mat#cv##QAE#ABV01##Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 21 error LNK2019: unresolved external symbol "public: void __thiscall cv::Algorithm::set(char const *,double)" (?set#Algorithm#cv##QAEXPBDN#Z) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 22 error LNK2019: unresolved external symbol "int __cdecl cv::_interlockedExchangeAdd(int *,int)" (?_interlockedExchangeAdd#cv##YAHPAHH#Z) referenced in function "public: __thiscall cv::Mat::Mat(class cv::Mat const &)" (??0Mat#cv##QAE#ABV01##Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 23 error LNK2019: unresolved external symbol _cvCvtColor referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 24 error LNK2019: unresolved external symbol _cvShowImage referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 25 error LNK2019: unresolved external symbol _cvLoadImage referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 26 error LNK2019: unresolved external symbol _cvSaveImage referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 27 error LNK2019: unresolved external symbol _cvWaitKey referenced in function "void __cdecl getBinaryImage(void)" (?getBinaryImage##YAXXZ) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 28 error LNK2019: unresolved external symbol _cvCreateCameraCapture referenced in function _main C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 29 error LNK2019: unresolved external symbol _cvQueryFrame referenced in function _main C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 30 error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread#cv##YA?AVMat#1#ABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##H#Z) referenced in function "void __cdecl read_csv(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::vector<class cv::Mat,class std::allocator<class cv::Mat> > &,class std::vector<int,class std::allocator<int> > &,char)" (?read_csv##YAXABV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##AAV?$vector#VMat#cv##V?$allocator#VMat#cv###std###2#AAV?$vector#HV?$allocator#H#std###2#D#Z) C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 31 error LNK2019: unresolved external symbol "class cv::Ptr<class cv::FaceRecognizer> __cdecl cv::createLBPHFaceRecognizer(int,int,int,int,double)" (?createLBPHFaceRecognizer#cv##YA?AV?$Ptr#VFaceRecognizer#cv###1#HHHHN#Z) referenced in function __catch$?getFace##YAXXZ$0 C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\PAD_visualEngine\Source.obj PAD_visualEngine
Error 32 error LNK1120: 31 unresolved externals C:\Users\Parker\documents\visual studio 2013\Projects\PAD_visualEngine\Debug\PAD_visualEngine.exe PAD_visualEngine
I had a 2012 vs application of this project and it worked just fine, The steps I have done is setting the Additional library Directories as "C:\opencv\build\x86\vc12\lib" and the additional Include Directories as "C:\opencv\build\include". For safe measures I also set the path as C:\opencv. I don't really know what I am forgetting? I thank you in advance for the help!
here is the code:
#include "opencv2/opencv.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
using namespace cv;
#define CV_IMWRITE_JPEG_QUALITY 1
#define CV_IMWRITE_PNG_COMPRESSION 16
#define CV_IMWRITE_PXM_BINARY 32
vector<Mat> images;
vector<int> labels;
void getBinaryImage()
{
IplImage *gray, *binary, *dest, *a;
a = cvLoadImage("out2.jpg");
gray = cvCreateImage(cvSize(a->width, a->height), IPL_DEPTH_8U, 1);
//binary=cvCreateImage(cvSize(a->width,a->height), IPL_DEPTH_8U,1);
dest = cvCreateImage(cvSize(a->width, a->height), IPL_DEPTH_8U, 1);
cvCvtColor(a, gray, CV_BGR2GRAY);
//cvThreshold(gray,binary,30,255,THRESH_BINARY);
cvInRangeS(a, cvScalar(1, 1, 1), cvScalar(120, 100, 300), dest);
cvSaveImage("out2_gray.jpg", dest);
cvShowImage("inrangGray", dest);
cvWaitKey(0);
}
void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';')
{
std::ifstream file(filename.c_str(), ifstream::in);
if (!file){
string error = "no valid input csv file";
cout << error;
}
string line, path, classlabel;
while (getline(file, line)){
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if (!path.empty() && !classlabel.empty()){
images.push_back(imread(path, 0));
labels.push_back(atoi(classlabel.c_str()));
}
}
}
void getFace()
{
try{
read_csv("file.csv", images, labels);
}
catch (cv::Exception& e){
cerr << "error opening file info.csv";
exit(1);
}
try{
if (images.size() <= 1){
string error = "this app needs at leaset 2 images";
cout << error;
}
int height = images[0].rows;
Mat testImage = images[images.size() - 1];
int testLab = labels[labels.size() - 1];
images.pop_back();
labels.pop_back();
Ptr<FaceRecognizer>model = createLBPHFaceRecognizer();
model->train(images, labels);
int predictedlabel = model->predict(testImage);
string result = format("predicted=%d/ actual=%d", predictedlabel, testLab);
cout << result << endl;
model->set("threshold", 0.0);
predictedlabel = model->predict(testImage);
cout << "predicted class = " << predictedlabel << endl;
}
catch (cv::Exception& e){
cerr << "overall error";
}
}
int main(int argc, char** argv)
{
/*VideoCapture cap;
// open the default camera, use something different from 0 otherwise;
// Check VideoCapture documentation.
if(!cap.open(0))
return 0;
for(;;)
{
Mat frame;
cap >> frame;
if( frame.empty() ) break; // end of video stream
imshow("capture", frame);
if( (waitKey() & 255) == 27 ) break; // stop capturing by pressing ESC
}
// the camera will be closed automatically upon exit
// cap.close();
return 0; */
int p[3];
CvCapture *pCapturedImage = cvCreateCameraCapture(-1);
IplImage *pSaveImg = cvQueryFrame(pCapturedImage);
pSaveImg = cvQueryFrame(pCapturedImage);
p[0] = CV_IMWRITE_JPEG_QUALITY;
p[1] = 100;
p[2] = 0;
//cvSaveImage("out2.jpg", pSaveImg, p);
//getBinaryImage();
getFace();
return 0;
}

You are getting those errors because the linker doesn't know in which library to look for the used methods. You can try adding the names of those libraries (depending on the methods you are using, try adding opencv_core248.lib, etc.) in Project properties->Linker->Input->Additional dependencies.
The second method is by adding the additional dependencies before the main function via pragma comments, as follows:
#pragma comment (lib, "opencv_core248d.lib")
#pragma comment (lib, "opencv_highgui248d.lib")
#pragma comment (lib, "opencv_imgproc248d.lib")
#pragma comment (lib, "opencv_video248d.lib")
#pragma comment (lib, "opencv_features2d248d.lib")
If you are building a release version, remove the "d" letter before the extension (opencv_core248.lib, etc.)
Let me know if that works for you!
Best regards

Check if your platform is win32 or x64(Solution Properties-->Configuration -->Platform column). I faced similar issue when my platform was win32 and the linker was trying to link using x64.

Related

LNK2019 error when building MySQL codei n VIsual Studio C++

I've spent about two days now trying to get this to work but I still keep getting the same error with every method I do. I'm new to connecting MySQL to C++ so I'm a bit lost and every time I try to compile it, the thing spits out LNK2019 error. I'm using Visual Studio 2022.
#include <iostream>
#include <mysql.h>
using namespace std;
// DATABASE STUFF
struct connection_details {
const char* server, * user, * password, * database;
};
MYSQL* mysql_connection_setup(struct connection_details mysql_details) {
MYSQL* connection = mysql_init(NULL);
if (!(mysql_real_connect(connection, mysql_details.server, mysql_details.user, mysql_details.password, mysql_details.database, 0, NULL, 0))) {
cout << "Connection Error: " << mysql_error(connection) << endl;
exit(1);
}
return connection;
}
MYSQL_RES* mysql_execute_query(MYSQL* connection, const char* sql_query) {
if (mysql_query(connection, sql_query)) {
cout << "MYSQL Query Error: " << mysql_error(connection) << endl;
exit(1);
}
return mysql_use_result(connection);
}
// MAIN FUNCTION
int main(int argc, char const* argv[]) {
MYSQL* con;
MYSQL_RES* res;
MYSQL_ROW row;
struct connection_details mysql_db;
mysql_db.server = "localhost";
mysql_db.user = "root";
mysql_db.password = "tAblE4wTe3";
mysql_db.database = "test";
con = mysql_connection_setup(mysql_db);
res = mysql_execute_query(con, "select * from table1");
cout << "Displaying Database:\n" << endl;
while ((row = mysql_fetch_row(res)) != NULL) {
cout << row[0] << " | " << row[1] << " | " << row[2] << endl;
}
mysql_free_result(res);
mysql_close(con);
return 0;
}
Errors it shows:
1>------ Build started: Project: Test, Configuration: Debug x64 ------
1>main.obj : error LNK2019: unresolved external symbol mysql_error referenced in function "struct MYSQL * __cdecl mysql_connection_setup(struct connection_details)" (?mysql_connection_setup##YAPEAUMYSQL##Uconnection_details###Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_init referenced in function "struct MYSQL * __cdecl mysql_connection_setup(struct connection_details)" (?mysql_connection_setup##YAPEAUMYSQL##Uconnection_details###Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_real_connect referenced in function "struct MYSQL * __cdecl mysql_connection_setup(struct connection_details)" (?mysql_connection_setup##YAPEAUMYSQL##Uconnection_details###Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_query referenced in function "struct MYSQL_RES * __cdecl mysql_execute_query(struct MYSQL *,char const *)" (?mysql_execute_query##YAPEAUMYSQL_RES##PEAUMYSQL##PEBD#Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_use_result referenced in function "struct MYSQL_RES * __cdecl mysql_execute_query(struct MYSQL *,char const *)" (?mysql_execute_query##YAPEAUMYSQL_RES##PEAUMYSQL##PEBD#Z)
1>main.obj : error LNK2019: unresolved external symbol mysql_free_result referenced in function main
1>main.obj : error LNK2019: unresolved external symbol mysql_fetch_row referenced in function main
1>main.obj : error LNK2019: unresolved external symbol mysql_close referenced in function main
1>C:\Users\Administrator\Documents\Visual Studio 2022\C++ Projects\Test\x64\Debug\Test.exe : fatal error LNK1120: 8 unresolved externals
1>Done building project "Test.vcxproj" -- FAILED.
These are the include/library folder locations:
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libbinlogevents
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libbinlogstandalone
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libchangestreams
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libmysql
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\libservices
C:\Program Files\MySQL\Connector C++ 8.0\lib64\vs14
C:\Users\Administrator\Documents\Visual Studio 2022\mysql stuff\include
C:\Program Files\MySQL\Connector C++ 8.0\include
I've tried looking it up, and every forum, video, etc. that I try using to resolve doesn't work. I'm not sure if it's a 32-bit or 64-bit issue, though I don't think it is since all files point to 64-bit folders. I'm thinking it's something in my code but I'm very new to this so I can't really pinpoint it. Any help would be appreciated.
EDIT: I managed to solve it, just started the project from scratch and followed the visual studio docs and this video.

How do I configure AlgLib for VS2017?

I am compiling a alglib sample program (with a few changes):
#pragma once
# include "Source\RFLearn.h" \\appropriate header for this simple .cpp program.
# include <LinAlg.h>
# include <stdint.h>
# include <chrono> // for in-game frame clock.
int RFLearn::test_function()
{
alglib::real_2d_array a, b, c;
int n = 2000;
int i, j;
double timeneeded, flops;
// Initialize arrays
a.setlength(n, n);
b.setlength(n, n);
c.setlength(n, n);
for (i = 0; i<n; i++)
for (j = 0; j<n; j++)
{
a[i][j] = alglib::randomreal() - 0.5;
b[i][j] = alglib::randomreal() - 0.5;
c[i][j] = 0.0;
}
// Set global threading settings (applied to all ALGLIB functions);
// default is to perform serial computations, unless parallel execution
// is activated. Parallel execution tries to utilize all cores; this
// behavior can be changed with alglib::setnworkers() call.
alglib::setglobalthreading(alglib::parallel);
// Perform matrix-matrix product.
flops = 2 * pow((double)n, (double)3);
auto timer_start = std::chrono::high_resolution_clock::now();
alglib::rmatrixgemm(
n, n, n,
1.0,
a, 0, 0, 0,
b, 0, 0, 1,
0.0,
c, 0, 0);
auto timer_end = std::chrono::high_resolution_clock::now();
auto duration = timer_end - timer_start;
timeneeded = static_cast<double>(duration.count());
// Evaluate performance
printf("Performance is %.1f GFLOPS\n", (double)(1.0E-9*flops / timeneeded));
return 0;
}
I am confident linAlg is correctly linked (as well as all of its dependencies, particularly ap.h and ap.cpp) (Preferences->C++->AllOptions->Additional Include Directories -> aglib's source directory. Changing the link provides a different set of linker errors. AlgLib is a header only-library so I don't think I need to compile any library and add it in the linker.
When compiling this code I get the errors:
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: double * __thiscall alglib::real_2d_array::operator[](int)" (??Areal_2d_array#alglib##QAEPANH#Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall alglib::real_2d_array::~real_2d_array(void)" (??1real_2d_array#alglib##UAE#XZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: __thiscall alglib::real_2d_array::real_2d_array(void)" (??0real_2d_array#alglib##QAE#XZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "struct alglib::xparams const & const alglib::parallel" (?parallel#alglib##3ABUxparams#1#B)
1>RFLearn.obj : error LNK2001: unresolved external symbol "void __cdecl alglib::rmatrixgemm(int,int,int,double,class alglib::real_2d_array const &,int,int,int,class alglib::real_2d_array const &,int,int,int,double,class alglib::real_2d_array const &,int,int,struct alglib::xparams)" (?rmatrixgemm#alglib##YAXHHHNABVreal_2d_array#1#HHH0HHHN0HHUxparams#1##Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "double __cdecl alglib::randomreal(void)" (?randomreal#alglib##YANXZ)
1>RFLearn.obj : error LNK2001: unresolved external symbol "public: void __thiscall alglib::ae_matrix_wrapper::setlength(int,int)" (?setlength#ae_matrix_wrapper#alglib##QAEXHH#Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "void __cdecl alglib::setglobalthreading(struct alglib::xparams)" (?setglobalthreading#alglib##YAXUxparams#1##Z)
1>RFLearn.obj : error LNK2001: unresolved external symbol "struct alglib::xparams const & const alglib::xdefault" (?xdefault#alglib##3ABUxparams#1#B)
I intuit that the problem lies around here: http://www.alglib.net/translator/man/manual.cpp.html#gs_configuring
but I cannot make heads or tails of it. What's the next step?
I had a similar (not exact) problem and it went away just by adding the compiled the cpp files to my project and set "included in the project" to true.

LNK2019 error with Eclipse Paho MQTT C for a Visual Studio C++ project (win64)

I want to use the Eclipse Paho MQTT C library in a simple C++ program. For the library i used the the pre-build binaries for windows - see https://projects.eclipse.org/projects/technology.paho/downloads
C client for Windows 1.3.0 - 64 bit
I found the exact same issue in this talk LNK2019 error when compiling a Visual C++ Win32 project with Eclipse Paho MQTT.
For linkage in include I have the following setting:
C/C++ - Additional include: xxx\paho\eclipse-paho-mqtt-c-win64-1.3.0\include
Linker - additional Additional Library Directories
Linker - input - additional dependencies:
eclipse-paho-mqtt-c-win64-1.3.0\lib\paho-mqtt3cs.lib
eclipse-paho-mqtt-c-win64-1.3.0\lib\paho-mqtt3c.lib
eclipse-paho-mqtt-c-win64-1.3.0\lib\paho-mqtt3a.lib
eclipse-paho-mqtt-c-win64-1.3.0\lib\paho-mqtt3as.lib
My code is as follows:
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern "C" {
#include <MQTTClient.h>
#include <MQTTClientPersistence.h>
}
#define ADDRESS "xxx"
#define CLIENTID "ExampleClientSub"
#define TOPIC "xxx"
#define PAYLOAD "Hello World!"
#define QOS 1
#define TIMEOUT 10000L
int main()
{
MQTTClient client;
MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
int rc;
int ch;
MQTTClient_create(&client, ADDRESS, CLIENTID,
MQTTCLIENT_PERSISTENCE_NONE, NULL);
conn_opts.keepAliveInterval = 20;
conn_opts.cleansession = 1;
conn_opts.username = "roman.busse";
conn_opts.password = "VojUriLKhOsmzUJQ1lld";
MQTTClient_setCallbacks(client, NULL, connlost, msgarrvd, delivered);
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(EXIT_FAILURE);
}
printf("Subscribing to topic %s\nfor client %s using QoS%d\n\n"
"Press Q<Enter> to quit\n\n", TOPIC, CLIENTID, QOS);
MQTTClient_subscribe(client, TOPIC, QOS);
do
{
ch = getchar();
} while (ch != 'Q' && ch != 'q');
MQTTClient_unsubscribe(client, TOPIC);
MQTTClient_disconnect(client, 10000);
MQTTClient_destroy(&client);
return 0;
}
So like you can see i said to the compiler: "Yes this is a C lib". But all in all I get the same LNK2019 errors...
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _MQTTClient_setCallbacks
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_create referenced
in function _main paho_test C:\Users\rtreiber\documents\visual studio
2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_connect
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_disconnect
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_subscribe
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_unsubscribe
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_freeMessage
referenced in function "int __cdecl msgarrvd(void *,char *,int,struct
MQTTClient_message *)"
(?msgarrvd##YAHPAXPADHPAUMQTTClient_message###Z) paho_test C:\Users\rtreiber\documents\visual
studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_free referenced
in function "int __cdecl msgarrvd(void *,char *,int,struct
MQTTClient_message *)"
(?msgarrvd##YAHPAXPADHPAUMQTTClient_message###Z) paho_test C:\Users\rtreiber\documents\visual
studio 2017\Projects\paho_test\paho_test\paho_test.obj 1
Error LNK2019 unresolved external symbol _MQTTClient_destroy
referenced in function
_main paho_test C:\Users\rtreiber\documents\visual studio 2017\Projects\paho_test\paho_test\paho_test.obj 1 Error LNK1120 9
unresolved externals paho_test C:\Users\rtreiber\documents\visual
studio 2017\Projects\paho_test\Debug\paho_test.exe 1
So any ideas?

error LNK2019: unresolved external symbol

I'm fresh in c++ and I'm facing a problem in including C++ code in Matlab C Mex-file.
I have 5 files: RTIFederate.h, RTIFederate.cpp, RTIFedAmb.cpp, RTIFedAmb.h, RTI3.cpp. RTI3.cpp contains the MEX modules. I'm getting the following errors while compiling with MEX command and libraries:
Creating library C:\Users\Nudel\AppData\Local\Temp\mex_DBx_sv\templib.x and object
C:\Users\Nudel\AppData\Local\Temp\mex_DBx_sv\templib.exp
RTI3.obj : error LNK2019: unresolved external symbol "class rti1516e::ObjectInstanceHandle DistributedParametersLine" (?DistributedParametersLine##3VObjectInstanceHandle#rti1516e##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * IEC_Model" (?IEC_Model##3PAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * IEC_Attribute" (?IEC_Attribute##3PAV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "class rti1516e::ObjectInstanceHandle PowerResource" (?PowerResource##3VObjectInstanceHandle#rti1516e##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "class rti1516e::AttributeHandle * _classattribute" (?_classattribute##3PAVAttributeHandle#rti1516e##A) referenced in function "void __cdecl mdlOutputs(struct SimStruct_tag *,int)" (?mdlOutputs##YAXPAUSimStruct_tag##H#Z)
RTI3.obj : error LNK2019: unresolved external symbol "public: __thiscall RTIFedAmb::RTIFedAmb(void)" (??0RTIFedAmb##QAE#XZ) referenced in function "public: void __thiscall RTIFederate::run(void)" (?run#RTIFederate##QAEXXZ)
RTI3.mexw32 : fatal error LNK1120: 6 unresolved externals
C:\PROGRA~1\MATLAB\R2011B\BIN\MEX.PL: Error: Link of 'RTI3.mexw32' failed
My RTI3.cpp has the following piece of code:
#include "RTIFederate.cpp"
static void mdlOutputs(SimStruct *S, int_T tid)
{
RTIFederate *c = (RTIFederate*) ssGetPWork(S)[0];
// LĂȘ a porta de entrada correspondente
time_T offset = ssGetOffsetTime(S,0);
time_T timeOfNextHit = ssGetT(S) + offset ;
ssSetTNext(S, timeOfNextHit);
for(int_T i=0;i<NUM_INPUTS;i++) {
int *dims = ssGetInputPortDimensions(S, i);
int frameSize = dims[0]; // Tamanho do campo (se for trifasico sera 3 , por ex
int numChannels = dims[1];
if((ssGetInputPortWidth(S,i)<1) ||(ssGetInputPortWidth(S,i)>1)|| (frameSize>1)) {
InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S, i);
real_T *y = ssGetOutputPortRealSignal(S,i);
int_T width = ssGetOutputPortWidth(S,i);
mexPrintf("%s%d%s%s%d\n","Num da entrada ->",i," ","Num largura > ",width);
for (int_T j=0;j<width;j++){
*y++ =*uPtrs[j];
mexPrintf("%s%u%s\n","IEC_Model[",i,"]--",IEC_Attribute[i].c_str());
if(IEC_Model[i].compare("DistributedParametersLine")!=0) {
if(IEC_Attribute[i].compare("Voltage")) {
mexPrintf("%s%u%s%f\n","Voltage[",j,"]-->",*uPtrs[j]);
c->AtualizaValoresdeAtributos(DistributedParametersLine,_classattribute[0],*uPtrs[j],timeOfNextHit);
} else if(IEC_Attribute[i].compare("Current")) {
mexPrintf("%s%u%s%f\n","Current[",j,"]-->",*uPtrs[j]);
c->AtualizaValoresdeAtributos(DistributedParametersLine,_classattribute[0],*uPtrs[j],timeOfNextHit);
}
} // end if IEC_Model
mexPrintf("%s%f\n","Avanco de tempo1->",timeOfNextHit);
} // end for
} else {
double *u1=(double *) ssGetInputPortSignal(S, i);
real_T *y1 = ssGetOutputPortRealSignal(S,i);
(*y1) =(*u1); //copia entrada para saida
mexPrintf("%s%f\n","Avanco de tempo2->",timeOfNextHit);
c->AtualizaValoresdeAtributos(PowerResource,_classattribute[0],*u1,timeOfNextHit);
} // end else
} // end for i
}
/* Function: mdlTerminate */
static void mdlStart(SimStruct *S)
{
char *buf;
size_t buflen;
int status;
buflen = mxGetN((ssGetSFcnParam(S, 2)))*sizeof(mxChar)+1 ; // read 3rd param
buf = (char *)mxMalloc(buflen); //alloc mem
status = mxGetString((ssGetSFcnParam(S, 2)), buf,(mwSize)buflen);
ssGetPWork(S)[0] = (void *) new RTIFederate; // store new C++ object in the
RTIFederate *c = (RTIFederate *) ssGetPWork(S)[0];
c->InterpretaArqMDL(buf); // Rotina que trata da interpretacao dos objetos da norma IEC 61968
c->run();
...
}
On top of RTIFederate.cpp I have declared the following:
#include "RTIFedAmb.h"
#include "RTIFederate.h"
and in the file RTIFederate.h I declared:
class RTIFederate
{
public:
RTIambassador *rtiamb;
RTIFedAmb *fedamb;
// variables //
ObjectClassHandle _ClassObject[300];
AttributeHandle _classattribute[300];
string IEC_Model[29],IEC_Attribute[20];//
// public methods //
RTIFederate();
virtual ~RTIFederate();
...
}
extern ObjectClassHandle _ClassObject[300];
extern AttributeHandle _classattribute[300];
extern AttributeHandleSet attributeSet[300];
extern ObjectInstanceHandle ProtectedSwitch,Recloser,ThreePhaseBreaker,ACLineSegment,DistributedParametersLine;
extern RTIambassador *rtiamb;
extern RTIFedAmb *fedamb;
Also there is a piece of code in RTIFedAmb.h:
//methods
RTIFedAmb();
virtual ~RTIFedAmb() throw();
Can anyone help me to explain what am I missing ?
So, you want to include c-lib in your c ++ project. That's fine but you should note one thing: c ++ differs a bit from c. And you found a good illustration.
c ++ "deforms" function names in lib while c does not. Nevertheless you still can use c libraries. Do it so:
extern "C" ObjectClassHandle _ClassObject[300];
extern "C" AttributeHandle _classattribute[300];
extern "C" AttributeHandleSet attributeSet[300];
extern "C" ObjectInstanceHandle ProtectedSwitch,Recloser,ThreePhaseBreaker,ACLineSegment,DistributedParametersLine;
extern "C" RTIambassador *rtiamb;
extern "C" RTIFedAmb *fedamb;
Hope it will help you.

link time error in vc++ when using confuse library

I am trying to use confuse library on windows. I get a link time error when confuse is compiled in vc++. how to resolve it. Please note that libConfuse is a configuration file parser library and written in C.
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_getnint referenced in function "void __cdecl print_ask(struct cfg_opt_t *,unsigned int,struct _iobuf *)" (?print_ask##YAXPAUcfg_opt_t##IPAU_iobuf###Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_title referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark##YAHPAUcfg_t##PAUcfg_opt_t###Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getstr referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark##YAHPAUcfg_t##PAUcfg_opt_t###Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_getnsec referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark##YAHPAUcfg_t##PAUcfg_opt_t###Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_opt_size referenced in function "int __cdecl cb_validate_bookmark(struct cfg_t *,struct cfg_opt_t *)" (?cb_validate_bookmark##YAHPAUcfg_t##PAUcfg_opt_t###Z)
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_free referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_print referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_set_print_func referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnint referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnfloat referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnstr referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getsec referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getbool referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getnsec referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_size referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_setstr referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_getint referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_parse referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_set_validate_func referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_init referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__cfg_include referenced in function _main
1>F:\products\testconfuse\testconfuse\Debug\testconfuse.exe : fatal error LNK1120: 21 unresolved externals
1>Build log was saved at "file://f:\products\testconfuse\testconfuse\testconfuse\Debug\BuildLog.htm"
1>testconfuse - 22 error(s), 0 warning(s)
The program has two file main.cpp and test.conf . Also not that we need to download http://bzero.se/confuse/confuse-2.6.zip and give use library libConfuse.lib which is present inside confuse-2.6\windows\msvc6\libConfuse
///// main.cpp
extern "C"
{
#include <confuse.h>
}
#include <string.h>
void print_func(cfg_opt_t *opt, unsigned int index, FILE *fp)
{
fprintf(fp, "%s(foo)", opt->name);
}
void print_ask(cfg_opt_t *opt, unsigned int index, FILE *fp)
{
int value = cfg_opt_getnint(opt, index);
switch(value) {
case 1:
fprintf(fp, "yes");
break;
case 2:
fprintf(fp, "no");
break;
case 3:
default:
fprintf(fp, "maybe");
break;
}
}
/* function callback
*/
int cb_func(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv)
{
int i;
/* at least one parameter is required */
if(argc == 0) {
cfg_error(cfg, "Too few parameters for the '%s' function",
opt->name);
return -1;
}
printf("cb_func() called with %d parameters:\n", argc);
for(i = 0; i < argc; i++)
printf("parameter %d: '%s'\n", i, argv[i]);
return 0;
}
/* value parsing callback
*
* VALUE must be "yes", "no" or "maybe", and the corresponding results
* are the integers 1, 2 and 3.
*/
int cb_verify_ask(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result)
{
if(strcmp(value, "yes") == 0)
*(long int *)result = 1;
else if(strcmp(value, "no") == 0)
*(long int *)result = 2;
else if(strcmp(value, "maybe") == 0)
*(long int *)result = 3;
else {
cfg_error(cfg, "Invalid value for option %s: %s", opt->name, value);
return -1;
}
return 0;
}
int cb_validate_bookmark(cfg_t *cfg, cfg_opt_t *opt)
{
/* only validate the last bookmark */
cfg_t *sec = cfg_opt_getnsec(opt, cfg_opt_size(opt) - 1);
if(!sec)
{
cfg_error(cfg, "section is NULL!?");
return -1;
}
if(cfg_getstr(sec, "machine") == 0)
{
cfg_error(cfg, "machine option must be set for bookmark '%s'",
cfg_title(sec));
return -1;
}
return 0;
}
int main(int argc, char **argv)
{
unsigned int i;
cfg_t *cfg;
unsigned n;
int ret;
static cfg_opt_t proxy_opts[] = {
CFG_INT("type", 0, CFGF_NONE),
CFG_STR("host", 0, CFGF_NONE),
CFG_STR_LIST("exclude", "{localhost, .localnet}", CFGF_NONE),
CFG_INT("port", 21, CFGF_NONE),
CFG_END()
};
static cfg_opt_t bookmark_opts[] = {
CFG_STR("machine", 0, CFGF_NONE),
CFG_INT("port", 21, CFGF_NONE),
CFG_STR("login", 0, CFGF_NONE),
CFG_STR("password", 0, CFGF_NONE),
CFG_STR("directory", 0, CFGF_NONE),
CFG_BOOL("passive-mode", cfg_false, CFGF_NONE),
CFG_SEC("proxy", proxy_opts, CFGF_NONE),
CFG_END()
};
cfg_opt_t opts[] = {
CFG_INT("backlog", 42, CFGF_NONE),
CFG_STR("probe-device", "eth2", CFGF_NONE),
CFG_SEC("bookmark", bookmark_opts, CFGF_MULTI | CFGF_TITLE),
CFG_FLOAT_LIST("delays", "{3.567e2, 0.2, -47.11}", CFGF_NONE),
CFG_FUNC("func", &cb_func),
CFG_INT_CB("ask-quit", 3, CFGF_NONE, &cb_verify_ask),
CFG_INT_LIST_CB("ask-quit-array", "{maybe, yes, no}",
CFGF_NONE, &cb_verify_ask),
CFG_FUNC("include", &cfg_include),
CFG_END()
};
#ifndef _WIN32
/* for some reason, MS Visual C++ chokes on this (?) */
printf("Using %s\n\n", confuse_copyright);
#endif
cfg = cfg_init(opts, CFGF_NOCASE);
/* set a validating callback function for bookmark sections */
cfg_set_validate_func(cfg, "bookmark", &cb_validate_bookmark);
ret = cfg_parse(cfg, argc > 1 ? argv[1] : "test.conf");
printf("ret == %d\n", ret);
if(ret == CFG_FILE_ERROR) {
perror("test.conf");
return 1;
} else if(ret == CFG_PARSE_ERROR) {
fprintf(stderr, "parse error\n");
return 2;
}
printf("backlog == %ld\n", cfg_getint(cfg, "backlog"));
printf("probe device is %s\n", cfg_getstr(cfg, "probe-device"));
cfg_setstr(cfg, "probe-device", "lo");
printf("probe device is %s\n", cfg_getstr(cfg, "probe-device"));
n = cfg_size(cfg, "bookmark");
printf("%d configured bookmarks:\n", n);
for(i = 0; i < n; i++) {
cfg_t *pxy;
cfg_t *bm = cfg_getnsec(cfg, "bookmark", i);
printf(" bookmark #%u (%s):\n", i+1, cfg_title(bm));
printf(" machine = %s\n", cfg_getstr(bm, "machine"));
printf(" port = %d\n", (int)cfg_getint(bm, "port"));
printf(" login = %s\n", cfg_getstr(bm, "login"));
printf(" passive-mode = %s\n",
cfg_getbool(bm, "passive-mode") ? "true" : "false");
printf(" directory = %s\n", cfg_getstr(bm, "directory"));
printf(" password = %s\n", cfg_getstr(bm, "password"));
pxy = cfg_getsec(bm, "proxy");
if(pxy) {
int j, m;
if(cfg_getstr(pxy, "host") == 0) {
printf(" no proxy host is set, setting it to 'localhost'...\n");
/* For sections without CFGF_MULTI flag set, there is
* also an extended syntax to get an option in a
* subsection:
*/
cfg_setstr(bm, "proxy|host", "localhost");
}
printf(" proxy host is %s\n", cfg_getstr(pxy, "host"));
printf(" proxy type is %ld\n", cfg_getint(pxy, "type"));
printf(" proxy port is %ld\n", cfg_getint(pxy, "port"));
m = cfg_size(pxy, "exclude");
printf(" got %d hosts to exclude from proxying:\n", m);
for(j = 0; j < m; j++) {
printf(" exclude %s\n", cfg_getnstr(pxy, "exclude", j));
}
} else
printf(" no proxy settings configured\n");
}
printf("delays are (%d):\n", cfg_size(cfg, "delays"));
for(i = 0; i < cfg_size(cfg, "delays"); i++)
printf(" %G\n", cfg_getnfloat(cfg, "delays", i));
printf("ask-quit == %ld\n", cfg_getint(cfg, "ask-quit"));
/* Using cfg_setint(), the integer value for the option ask-quit
* is not verified by the value parsing callback.
*
*
cfg_setint(cfg, "ask-quit", 4);
printf("ask-quit == %ld\n", cfg_getint(cfg, "ask-quit"));
*/
/* The following commented line will generate a failed assertion
* and abort, since the option "foo" is not declared
*
*
printf("foo == %ld\n", cfg_getint(cfg, "foo"));
*/
cfg_addlist(cfg, "ask-quit-array", 2, 1, 2);
for(i = 0; i < cfg_size(cfg, "ask-quit-array"); i++)
printf("ask-quit-array[%d] == %ld\n",
i, cfg_getnint(cfg, "ask-quit-array", i));
/* print the parsed values to another file */
{
FILE *fp = fopen("test.conf.out", "w");
cfg_set_print_func(cfg, "func", print_func);
cfg_set_print_func(cfg, "ask-quit", print_ask);
cfg_set_print_func(cfg, "ask-quit-array", print_ask);
cfg_print(cfg, fp);
fclose(fp);
}
cfg_free(cfg);
return 0;
}
// test.conf
# test config file
# this is a one line comment
// this is a C++-style one line comment
/*
* This is a C-style multi-line comment
*/
BackLog = 2147483647
bookmark heimdal {
login = "anonymous"
password = ${ANONPASS:-anonymous#}
directory = "/pub/heimdal/src"
machine = "ftp://ftp.pdc.kth.se:21"
proxy {
type = 1
host = ${HOST:-localhost} # environment variable substitution
#port = 21
#exclude = {"localhost" , ".localnet" , "fu.bar.net"}
exclude += {.aol.com , .sf.net}
}
}
probe-device = "eth1"
# probe-device += "eth3" # error, probe-device is not a list
bookmark gazonk {
machine = "ssh://localhost"
login = joe
passive-mode = true
directory = '/pub/dir with spaces/\
more' # continued on next line
port = 022 # in octal mode
proxy {} /* use default proxy */
}
bookmark ftp.du.se {
machine = "ftp.du.se"
// port = 0x21 /* hexadecimal */
login = ftp
proxy {
exclude = {.com.net}
}
}
/* functions can be called with variable number of arguments
*/
func( "one", "two", 'three',four )
func( 1, 2 )
//delays = {145.12345, .6,42, 4.987e2}
//delays += {0.1, 0.2, 0.3}
ask-quit = maybe
#ask-quit-array = {"maybe", "maybe", "maybe"}
ask-quit-array += {"no", "yes", "yes"}
include(inc.conf)
/////////////////////////////////
I have added libconfuse.lib inside linker->input->"additional depenendencies" and also given path of lib linker->General ->"additional link directory"
I have added libconfuse 2.6 and extracted it. I have used lib in it also config.h from its src dir. I have then compiled example program from libconfuse home page.
I think you didnt add a reference to a lib that is needed for the "confuselib" to work. Can you check your compiler linker includes and see if you added all the relevant confuse libraries ?
those methods are all defined in confuse.c; either you are not linking with the confuse library, or with another version, or you built the confuse library with an erroneous configuration.
The issue is fixed now . it was resolved when i gave lib path from F:\confuse-2.6\windows\msvc6\libConfuse to F:\confuse-2.6\windows\msvs.net\libConfuse\Release