DwfToolkit linking - linker

I would like to to use DwfToolkit in my app, but I have problem to link it.
The code:
// DWF Core headers
#include "dwfcore/String.h"
#include "dwfcore/Core.h"
#include "dwfcore/SkipList.h"
#include "dwfcore/InputStream.h"
using namespace DWFCore;
// WHIP! headers
#include "whiptk/whip_toolkit.h"
// DWF Toolkit headers
#include "dwf/Version.h"
#include "dwf/Toolkit.h"
#include "dwf/package/Manifest.h"
#include "dwf/package/EPlotSection.h"
#include "dwf/package/EModelSection.h"
using namespace DWFToolkit;
int _tmain(int argc, _TCHAR* argv[])
{
DWFString path("c:\\test.dwf");
DWFFile file(path);
DWFPackageReader reader( file );
return 0;
}
In linker options (Additional Dependencies) I added dwfcore.1.7.0.lib, dwftk_ro.7.7.0.lib, whiptk_ro.7.13.601.lib. After compile:
Error 902 error LNK2019: unresolved external symbol "__declspec(dllimport)
public: __thiscall DWFCore::DWFString::DWFString(wchar_t const *)"
(__imp_??0DWFString#DWFCore##QAE#PB_W#Z) referenced in function _wmain
When I erase line DWFPackageReader reader( file ); from code, program is builded.

If you are linking static lib add dwfcore_static in the preprocessor.

Related

ESP-IDF on Eclipse IDE error with external Library

I am using esp-idf v4.1.1 with different compilers, I have used Visual Studio Code and Eclipse IDE with Espressif tool installed.
My intention is that I want to use an external library that, at the moment, only has a function that does a SHA256 hash for which the openssl sha library (<openssl/sha.h>) is used.
The problem is that I include the library as a component to my project and I call it from the main but I get the following error when building the project.
(https://i.stack.imgur.com/3EECj.png)
If I try it in the Eclipse IDE I get more information about the error and I get "undefined reference to SHA256_INIT()" as for the rest of the functions.
See main.c, dual.c and dual.h code:
main.c:
#include <stdio.h>
#include "dual.h"
void app_main(void)
{
printf("Empezamos");
char * data = "hola";
char * e = generateHashSHA256(data);
printf("%s",e);
}
Dual.c:
#include <stdio.h>
#include "dual.h"
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>
#include <openssl/sha.h>
char * generateHashSHA256(char *data){
SHA256_CTX ctx;
u_int8_t results[SHA256_DIGEST_LENGTH];
int n;
n = strlen(data);
SHA256_Init(&ctx);
SHA256_Update(&ctx, (u_int8_t *)data, n);
SHA256_Final(results, &ctx);
char *newString;
newString = malloc(sizeof(char)*SHA256_DIGEST_LENGTH*2);
memset(newString, 0, sizeof(char)*SHA256_DIGEST_LENGTH*2);
for(n=0;n<SHA256_DIGEST_LENGTH;n++)
{
printf(newString, "%s%02x", newString, results[n]);
}
return newString;
}
And Dual.h:
char * generateHashSHA256(char *data);
and CMake files:
CMake of component Dual:
idf_component_register(SRCS "dual.c"
INCLUDE_DIRS "include"
)
CMake of main folder:
idf_component_register(SRCS "main.c"
INCLUDE_DIRS ".")
CMake of project folder:
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(template-app)
I compiled the library from the terminal with "gcc -o name main.c -lssl -lcrypto" and it works correctly but when compiling it in an esp-idf project nothing...
Please HELP!
I have tried everything, I have included the openssl libraries in all the esp-idf directories, I have put the paths in the CMake... etc.

Unresolved external symbol bcrypt_gensalt

I have one problem with library <bcrypt.h>. Compiler say error with function bcrypt_gensalt.
#include <iostream>
#include <bcrypt.h>
using namespace std;
int main() {
const char* passwd = "Secret_Password";
char results[BCRYPT_HASHSIZE];
bcrypt_gensalt(10, results);
system("pause");
return 0;
}
Error from compiler:
unresolved external symbol bcrypt_gensalt referenced in function main
You need to reference Bcrypt.lib.
See here: http://msdn.microsoft.com/en-us/library/ba1z7822.aspx.

using windows.h along with main()

I must use main() and call a function from windows.h.
The following code wants a WinMain() function to be used instead of main().
#include <windows.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
int vk_Shift = 16;
while (1)
{
if (GetAsyncKeyState(vk_Shift) < 0)
{
printf("Shift is pressed\n");
}
}
}
Error
Error 1 error LNK2019: unresolved external symbol _WinMain#16
referenced in function ___tmainCRTStartup
Error 2 error LNK1120: 1 unresolved externals
How can I get this work in VS2013?
Okay, guys, I got it.
Felix Palmen's advice works.
... ... I guess configuring it as "console" application should do the trick.
So, what I did is, I changed my project's preference from WIDOWS to CONSOLE.

C / CUDA implementation with external variables produces linker error (unresolved external symbol)

I have a C-Project, which I would like to boost using a CUDA-module. But somehow, the externally defined variables can not be resolved. I am using Microsoft Visual C++ 2010 Express and CUDA Toolkit 5.0.
The following shows my minimal (not) working example:
main.c:
#include "main.h"
#include <stdio.h>
#include "cuda_test.cu"
int main( int argc, const char* argv[] )
{
testfunc();
return 1;
}
main.h:
#ifndef main_h
#define main_h
extern float PI;
#endif
testfile.c:
#include "main.h"
float PI = 3;
cuda_test.cu:
#include "main.h"
#include <stdio.h>
void testfunc()
{
printf("Hello from cudafile: %E", PI);
}
This yields the following error:
1>------ Build started: Project: cuda_min, Configuration: Debug Win32 ------
1>cuda_test.cu.obj : error LNK2001: unresolved external symbol "float PI" (?PI##3MA)
1>D:\Backup\diplomarbeit\cuda_xanthos\cuda_min\Debug\cuda_min.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
When passing the variable PI to the function testfunc, I get the desired behavior. This is what I am doing in my project (which actually uses the CUDA-device), but I really do not want to pass about 20 variables to my functions.
I suppose I am missing some setting for nvcc...
Any help would be much appreciated.
.cu is compiled and linked as .cpp, not .c. So, you can either rename your .c files to .cpp, or use extern "C" in your .cu file.

OpenCV242 on eclipse in windows

I want to work with OpenCV2.4.2 . and I tried a simple progam to test if it'll work here is the code :
#include "stdlib.h"
#include "stdio.h"
#include "math.h"
#include "cv.h"
#include "highgui.h"
int main(int argc, char *argv[])
{
// Nothing but create a window
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 100, 100);
cvWaitKey(0);
return 0;
}
wenn I try to build and run this I get this error message from Eclipse :
fatal error: opencv2/core/core_c.h: No such file or directory
line 63, external location: D:\opencv\include\opencv\cv.h C/C++ Problem
Symbol 'CV_WINDOW_AUTOSIZE' could not be resolved source.c line 18 Semantic Error
Any Idea why it doesn't work ??
Because the compiler does not know the location of opencv headers.

Resources