我有一個模板類的頭文件.HPP:C++模板類的顯式實例與海灣合作委員會未能/ NDK
Rage.hpp:
//various includes...
template<typename... Args>
class Rage : public PlatformManagerDelegate
{
bool paused;
//other variables...
public:
Rage(Args... args);
void pushInitialState(std::unique_ptr<State> state);
//other methods...
};
,它是在源的.cpp實現文件,用明確的情況下,在文件的結尾:
Rage.cpp:
#include "Rage.hpp"
#include <android_native_app_glue.h>
//other includes...
template<typename... Args>
Rage<Args...>::Rage(Args... args) : paused(false)
{
//some code...
}
template<typename... Args>
void Rage<Args...>::pushInitialState(std::unique_ptr<State> state)
{
//some more code...
}
//more methods...
template class Rage<>;
template class Rage<struct android_app*>;
編譯在main.cpp中
#include "Rage.hpp"
#include <android_native_app_glue.h>
void android_main(struct android_app* appState)
{
app_dummy();
Rage<>* clientInstance = new Rage<>();
clientInstance->beginRun();
}
下面給出:使用MSVC從Visual Studio 2013(明顯改變android_main標準的主要功能)
undefined reference to 'Rage<>::beginRun()'
undefined reference to 'Rage<>::Rage()'
此代碼編譯完全正常,所以任何幫助,我似乎做錯了,讓它在GCC/NDK編譯將不勝感激!
你如何鏈接代碼? –
我沒有改變任何與鏈接有關的事情,所以不知道tbh,我應該發佈我的Android.mk和Application.mk?其他一切似乎都很好(內部項目和外部項目)。 – Rajveer
不是,只是連接線。 –