我想问一个有关编译C ++代码时遇到的错误的问题。我在Player.CPP文件中的PSPlayer.CPP和PICost中声明了一个函数“ PSCost”,并在其中调用了此函数。另一个文件。
Commun.cpp
class AlertWakeLock {
companion object {
private var wakeLock: PowerManager.WakeLock? = null
fun acquireWakeLock(context: Context) {
Log.d(TAG,"Acquiring cpu wake lock")
if (wakeLock != null) {
return
}
val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager
wakeLock = pm.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK or
PowerManager.ACQUIRE_CAUSES_WAKEUP or
PowerManager.ON_AFTER_RELEASE, "ToddlerTimer:WakeLock"
)
wakeLock!!.acquire()
}
fun releaseWakeLock() {
Log.d(TAG,"Releasing cpu wake lock")
if (wakeLock != null) {
wakeLock!!.release()
wakeLock = null
}
}
}
}
// ----- commun.cpp -------------
中的函数#include "Commun.h"
#include <cstdlib>
#include <algorithm>
#include "PSPlayer.h"
#include "PIPlayer.h"
extern float PICost(TRXs trx,int f,Individual * solution,AFP * afpProblem);
extern float PSCost(TRXs trx,int f,Individual * solution,AFP * afpProblem);
,我收到此错误:未定义引用'PSCost(trx,fi,solution,afpProblem)' 拜托,有人可以帮我吗?