codegenの使用(GUIインターフェース経由)でいくつか問題があります。
次の2つのファイルに基づいて、非常に単純なcベースの.exeプログラムを正常に構築できました。
coderand.m
function r = coderand() %#codegen
r = rand();
main.c
#include <stdio.h>
#include <stdlib.h>
#include "coderand.h"
int main()
{
printf("coderand=%g\n", coderand());
return 0;
}
ここで、main.cppの同じコードのmain.cを変更しようとすると、
main.cpp
#include <stdio.h>
#include <stdlib.h>
#include "coderand.h"
void main(int argc, char **argv)
{
printf("coderand=%g\n", coderand());
}
次のコンパイルエラーが発生します。
main.obj : error LNK2019: unresolved external symbol "double __cdecl coderand(void)" (?coderand@@YANXZ) referenced in function _main 25 F:\CoderTest\coderand.exe : fatal error LNK1120: 1 unresolved externals
どんな助けでも大歓迎です。
編集:-自分で解決...
同じ問題に苦しんでいる人のために...
コーダー->その他の設定->すべての設定->詳細設定->言語..CをC++に変更