Linker Error prevents me from initializing TA-LIB in C++ - c++

I'm having a problem with TA-LIB in my C++ project.
I just downloaded TA-lib (ta-lib-0.4.0-msvc.zip) and copy-and-pasted c folder to my project folder.
Because of a linker error, I can't go any further.
What I did:
I just downloaded TA-lib (ta-lib-0.4.0-msvc.zip) and copy-and-pasted c folder to my project folder.
include "c\include\ta_libc.h"
Is there anything wrong with my steps? Or any steps I missed?
#AlenL
Thank you for your help.
I included every proj files in IDE.
But the result is the same.
+) Error List
LNK2019 unresolved external symbol _TA_Shutdown referenced in function _main
LNK2019 unresolved external symbol _TA_Initialize referenced in function _main
LNK1120 2 unresolved externals

Look into the ta-lib\c\ide\vs2005\lib_proj folder and it's subfolders. You need to include the .vcproj files from the subfolders into your solution.

Related

How do i fix curl linker errors

i'm trying to use libcurl in my C++ application, but i'm running into linker errors.
I did add the include and lib folder in my project and added the .lib file in the additional dependencies.
Error: LNK2019 unresolved external symbol __imp__curl_easy_init referenced in function _main

Unresolved externals with google test

I have a project I am trying to add google-test unit testing to. It is structured like so:
VM (project)
some source files
BytecodePrograms.h
VMTest (project, made by add project -> google test -> link dynamically, test VM)
pch.h
test.cpp
I added my VM project as an include directory in VMTest properties -> c/c++ -> general -> additional include directories
contents of test.cpp are:
#include "pch.h"
#include "BytecodePrograms.h"
TEST(TestCaseName, TestName) {
EXPECT_EQ(8, VMFibonacciImp(6));
EXPECT_TRUE(true);
}
If I build, I get the following errors
Error LNK2019 unresolved external symbol "public: __thiscall WVM::WVM(void)" (??0WVM##QAE#XZ) referenced in function "int __cdecl VMFibonacciImp(int)" (?VMFibonacciImp##YAHH#Z) WVMTest C:\Users\WadeMcCall\source\repos\Virtual Machine Visual Scripting\WVMTest\test.obj 1
Error LNK2019 unresolved external symbol "public: __thiscall WVM::~WVM(void)" (??1WVM##QAE#XZ) referenced in function "int __cdecl VMFibonacciImp(int)" (?VMFibonacciImp##YAHH#Z) WVMTest C:\Users\WadeMcCall\source\repos\Virtual Machine Visual Scripting\WVMTest\test.obj 1
Error LNK2019 unresolved external symbol "public: int __thiscall WVM::interpret(class std::vector<int,class std::allocator<int> >)" (?interpret#WVM##QAEHV?$vector#HV?$allocator#H#std###std###Z) referenced in function "int __cdecl VMFibonacciImp(int)" (?VMFibonacciImp##YAHH#Z) WVMTest C:\Users\WadeMcCall\source\repos\Virtual Machine Visual Scripting\WVMTest\test.obj 1
However, my VM project defines my WVM class and uses it and can build and run and BytecodePrograms.h includes VM.h which has the declaration for this class.
I feel like this must just be a problem with the set up of my projects in Visual Studio somehow, but I have no idea. I have been googling for 2 days straight and have found other people with similar problems but their solution never seems to work for me.
Any ideas? Thanks.
I found a solution here: https://stackoverflow.com/a/19709712/8488701
Similar to what Steve suggested, except instead of creating a whole new project, I use a post-build event to build my project to a library and then link google test to that. The advantage of this over Steve's solution is that you don't have to modify your main project at all and you can still build a unit testing project on top of it.
This is a link error indicating that it found the .h file but couldn't find the actual implementation found in the .cpp. If you have a LIB project then visual studio may take the cpp code compiled into the LIB project and add it to your EXE project.
To incorporate the code into the test project, you have two options.
You can add the .cpp files in your VM Project to your Test project as well, but this is not usually done.
Instead, if your VM project is now an EXE I would recommend creating a new project called VMLib as a LIB project and then adding that project to both the test project and the VM EXE project.

Installing Glog linking error

I am new to programming. I want to install Glog on my Windows 10 system. I have followed the instructions found in a Stack Overflow thread with the same name.
I used cmake and Visual Studio 2015 to build the project.
First anomaly of the built file: I noticed that in the glog directory the header file "log_severity.h" was missing. To alleviate this problem, I copied the "log_severity.h" from the GitHub repository and pasted it.
http://imgur.com/QeLTnat
I then created a sample program that just initializes the logger by only using
google::InitGoogleLogging(argv[0]);
in the main.
Before compiling I direct the linker to include an additional include directory. This include directory is the one with the header files as in the second image (with the log_severity.h etc.):
http://imgur.com/yrjOIot
Yet I still receive a linking error when compiling the code:
1>Source.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl google::InitGoogleLogging(char const *)" (__imp_?InitGoogleLogging#google##YAXPEBD#Z) referenced in function main
1>D:\Documents\Programming\C++\Programme\GLogTest\GlogTest\x64\Debug\GlogTest.exe : fatal error LNK1120: 1 unresolved externals
What am I doing wrong?
Thanks a lot of any answers.
I solved it. When you build the project in visual studio, there is also an "Installation" folder inside the MS project. I forgot to build that as well!

C++ cURL linking error "unresolved external symbol _curl_easy_"

I am facing issues with the C++ cUrl Library on Windows, using Visual Studio 2012.
I have a CGI project which generates a .cgi file. This project includes another project called Library which is a Static Library Project.
In the Library project, I have the code which uses cUrl and includes curl/curl.h. I have referenced the Preprocessor Definition CURL_STATICLIB.
Then in my CGI Project, I have linked libcurl.lib to my project in Configuration Properties > Linker > Additional Dependencies.
But when I try to build the Solution, I still have those errors :
error LNK2001: unresolved external symbol _curl_easy_setopt in Library.lib(fct_util.obj)
error LNK2001: unresolved external symbol _curl_easy_perform in Library.lib(fct_util.obj)
error LNK2001: unresolved external symbol _curl_easy_init in Library.lib(fct_util.obj)
error LNK2001: unresolved external symbol _curl_easy_cleanup in Library.lib(fct_util.obj)
I already took a look at this topic : Unresolved symbols when linking a program using libcurl, as well as other related topics but couldn't find a solution for my problem.
Am I missing something ?
Kind Regards.
Credit to this guy helped me get further than any docs.
Still have a couple more issues.
https://www.youtube.com/watch?v=wjNyT5PhNvI
Then do this , someone in the video comments
Very important after you do everything in video.
Need to navigate back to solution right click properties
(see below comment)
"Thanks , it worked after i added Normaliz.lib;Ws2_32.lib;Wldap32.lib;Crypt32.lib;advapi32.lib in Additional Dependencies(property->linker->input)"

Problems including MATLAB "engine.h" for C++ code

I am trying to run the example code from the MATLAB Doc, but when I try to build the project in Visual Studio I get this error
fatal error C1083: Cannot open include file: 'engine.h': No such file or directory
The fact is that in the Doc I cannot find where to find the header to link it, they show the examples as if there was no need to do anything else, just do the
#include "engine.h";
Any ideas about how to solve this issue?
EDIT
I solved the first problem but now I get some errors reated to missing libs:
1>engwindemo.obj : error LNK2019: unresolved external symbol _engClose referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _mxGetClassName referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engGetVariable referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engOutputBuffer referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _mxDestroyArray referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engEvalString referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engPutVariable referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _mxGetPr referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _mxCreateDoubleMatrix_730 referenced in function _main
1>engwindemo.obj : error LNK2019: unresolved external symbol _engOpen referenced in function _main
I set the Path variable as told in the documentation, set the lib path and added some libraries and now I don't know what else can I do. I also rebooted VisualStudio in order to make the Path variable change effective.
Thanks in advance.
I finaly solved the problem. I was building a WIN32 project, while matlab is x64, so VisualStudio gives errors when you try to link 64-bit platforms. The solution is changing the Active Solution Platform to x64, inside Project Properties -> Configuration Manager.
It is well explained in the following link.
Thanks anyway for the answers, they were useful.
So, summarizing, to be able to compile and run a c++ code in VisualStudio2008 and Matlab2010 with engine.h, the following steps are required:
1.- Set Path variable in Advanced System Settings-> environment variables: C:\Program Files\MATLAB\R2010a\bin\win64 (or the path where libeng.dll is located)
2.- In project properties of VisualStudio, link in Additional Include directories of C++->General:
"C:\Program Files\MATLAB\R2010a\extern\include"
3.- In project properties, linker->general, Additional Library Directories:
"C:\Program Files\MATLAB\R2010a\extern\lib\win64\microsoft"
4.- Add the following libraries in Linker->Additional Dependencies:
libeng.lib
libmx.lib
5.- Change the Active Solution Platform to x64, in Configuration Manager as explained in the link.
Have you added the MATLAB include directory to your project's include path?
. The directory should be like "C:\Program Files\MATLAB\R2010a\extern\include"
In case you forgot, add the folder containing libmat.dll libmx.dll etc. to your path. For me that was:
C:\Program Files\MATLAB\R2012a\bin\win64
While the Jav_Rock's answer is completely correct, I want to add information about one of the points:
1.- Set Path variable in Advanced System Settings-> environment variables: C:\Program Files\MATLAB\R2010a\bin\win64 (or the path where
libeng.dll is located)
I spent three hours to understant what does it means, so I want to clarify this moment for future researchers.
You need to add the path of MATLAB Engine dll libraries to your Windows.
We can do it this way:
My Computer -> right click: Settings. Opened System window. Left bottom corner: Advanced System Settings
Advanced Tab
In the Environment variables for your user press Create... button and add this one:
Variable name: PATH
Variable value: C:\Program Files\MATLAB\R2016a\bin\win64
This path is reference on where is your libeng.dll located.
Important moment: it can require to restart VS or even restart computer.