- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
I have a cpp program which calls some c routines. I am trying to port the cpp program to DPC++. However when I compile the program by changing the compiler from "Intel C++ Compiler 2022" to "Intel(r) OneAPI DPC++ Compiler 2022", it fails to link. I made a test case as below:
------ main.cpp -------
extern "C" {
void f(int);
};
void code(int i)
{
f(i);
}
int main(void)
{
code(10);
}
---------- func.c ------
/* C code: */
#include <stdio.h>
void f(int i)
{
printf("f() is called!");
}
------------
--------------- output of Microsoft Visual Studio Community 2019 Version 16.11.16
1>------ ビルド開始: プロジェクト: dpcpp_call_c, 構成: Debug x64 ------
1>main-7ce443.obj : : error LNK2019: 未解決の外部シンボル f が関数 "void __cdecl code(int)" (?code@@YAXH@Z) で参照されました
1> 定義済みの一致する可能性があるシンボルに関するヒント:
1> "void __cdecl f(int)" (?f@@YAXH@Z)
1>C:\\Users\\mikei\\source\\repos\\dpcpp_call_c\\x64\\Debug\\dpcpp_call_c.exe : : error LNK1120: 1 件の未解決の外部参照
1>dpcpp: : error : linker command failed with exit code 1120 (use -v to see invocation)
1>プロジェクト "dpcpp_call_c.vcxproj" のビルドが終了しました -- 失敗。
========== ビルド: 0 正常終了、1 失敗、0 更新不要、0 スキップ
I think I am doing something stupid. Would you please teach me how to fix it?
Thanks.
-Mitsuru
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hi,
Thanks for the posting in Intel Communities.
Please find the below-attached codes where we are able to run successfully using the DPCPP compiler. Please find the below screenshot for more details:
Also, we have observed that you are using Microsoft Visual Studio(16.11.16) which is not supported by Intel oneAPI as of now. We recommend you to use the supported Microsoft Visual Studio versions with Intel oneAPI.
For the Microsoft Visual Studio Compatibility with Intel oneAPI, please find the below link :
Please let us know if you are still facing any issues.
Thanks & Regards,
Varsha
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hi,
Thank you for your quick response. I have confirmed it works. So do I need to put "
extern "C" {}" in all of my xxx.c programs? Wouldn't dpcpp asume "xxx.c" as c program?
-Mitsuru
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hi,
We are working on your issue. We will get back to you soon.
Thanks & Regards,
Varsha
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hi,
>>Wouldn't dpcpp asume "xxx.c" as c program?
Sorry for the inconvenience caused to you. DPCPP compiler won't assume as C code. Since the paths to the c and cpp compilers will differ, we need to use the extern C() explicitly to run the code successfully.
Thanks & Regards,
Varsha
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hi,
We have not heard back from you. Could you please provide an update on your issue?
Thanks & Regards,
Varsha
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Varsha,
Thank you for your quick response and support mails after. I found a temporal resolution for this. I change the compiler for all C programs to MS one by Visual Studio. And I am now struggling for other issues concerning how to rewrite kernel part for DPC++. So I will leave this issue for a while until I can run the kernel on Intel GPU.
Please close this issue.
Thank you again.
-Ikei
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hi,
>>Please close this issue.
Thanks for the confirmation. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.
Thanks & Regards,
Varsha

- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable