vendredi 19 août 2016

Visual Studio 2010 - Is it possible to link from Test Project to the object files of Code Project?

figure: my current Solution Structure (sorry, the language is chinese)

I added reference in TestProject to CodeProject, but seems I can only link to "square" function in mymath.c when CodeProject generates a static lib.

Usually, how would you set up a test project in order to link to the CodeProject? when CodeProject is to a console project (which generates exe, not a static lib). Or would you just add mymath.c as the source of TestProject?

Is there any prefered way? thanks.

[my CodeProject is written in C, and TestProject(following code) would be using gtest in C++]

#include "stdafx.h"

extern "C" {
#include "mymath.h"
}

int _tmain(int argc, _TCHAR* argv[])
{
    printf("%d\n", square(6) );   // <-------
    return 0;
}

which generates unresolved external symbol error of "square"

Aucun commentaire:

Enregistrer un commentaire