Creating a static library and linking to it using premake

I'm currently trying to learn how to use premake 4 to apply it to OpenGL sdk . I'm currently trying to create a Visual Studio 2010 solution that will build 2 projects, one of which is a static library, and the other contains the main main file with the main method.

This project is extremely simple and designed exclusively for training. In a static library project called Test, I have 2 files Test.h and Test.cpp. Test.h contains a prototype of the print () method. print () just prints a line to the console. Using premake, I linked the static library to the main project, and included the file Test.h in main.cpp. My problem is this: in VS2010, I get this error when trying to build:

1> main.obj: error LNK2019: unresolved external symbol "void __cdecl print (void)" (? Print @ @YAXXZ) referenced in function _main  
1>. \ Main.exe: fatal error LNK1120: 1 unresolved externals

Here is my code in 4 files, premake4.lua:

solution "HelloWorld"
    configurations {"Debug", "Release"}
project "Main"
    kind "ConsoleApp"
    language "C++"
    files{
        "main.cpp"

    }
    configuration "Debug"
        defines { "DEBUG" }
        flags { "Symbols" }

    configuration "Release"
        defines { "NDEBUG" }
        flags { "Optimize" } 
    links {"Test"}
project "Test"
    kind "StaticLib"
    language "C++"
    files{
        "test.h",
        "test.cpp"

    }

Test.cpp:

#include <iostream>

void print(){
    std::cout << "HELLO" << std::endl;
}

Test.h:

void print();

Main.cpp:

#include <conio.h>
#include "test.h"
int main(){
    print();
    getch();
    return 0;
}   

, getch(), , 0, getch() , , . , , . - , , , , .

+5
1
links {"Test"}

Lua Python. Lua, , ++. links "Release". , , configuration, kind, files .

Premake4 , , "Release" build ( Debug - ). , project configuration. , , - .

+9

All Articles