Polyspace-Code-Prover: User Program Error: User should provide a main routine, use -main or -main-generator.
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
When running Polyspace-Code-Prover, the log file results with:
"User Program Error: User should provide a main routine, use -main or -main-generator."
The project has a "main" function. Not sure what this response means then...
採用された回答
Hi,
Could you confirm a couple of things:
- The file that has the main function was indeed added to the Polyspace project (if you know which file has the main)? I understand you used polyspace-configure to generate a Polyspace project (or options file) from a Visual Studio project/solution. I just want to confirm that the file containing the main got added in this process.
- Your Visual Studio project has the regular main function that is just called main and not one of the Visual extensions of main like wWinMain? In which case, you have to use the option Main entry point.
7 件のコメント
jeremy longstreet
2020 年 7 月 28 日
編集済み: jeremy longstreet
2020 年 7 月 28 日
The solution file(SLN file) for VS is what I placed into the polyspace-config. In that, there are multiple projects that produce Executable files. Most of them do NOT have the problem of missing a 'main' when running PolyspaceCodeProver on them. All of them have the 'main' method in their projects.
This is what I entered at the command line for polyspace-config via a batch file: (the link to the sln file is given here)
polyspace-configure.exe -module -output-options-path C:\xxx\PolyspaceProjects\ "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe" C:\xxx\Source\TRUNK\Systems\DPM\DPM.sln
PolyspaceBugFinder on each Executable project(about 20 of them(psops) from polyspace-config. And so 20x polyspace-bug-finders are run:
polyspace-bug-finder -options-file c:\xxx\PolyspaceProjects\VS_Project_Y_exe.psopts -options-file "C:\xxx\PolyspaceProjects\BugFinderOptions.psops" -results-dir BugFinderResults_Y_exe
PolyspaceCodeProver on each Executable project(about 20 of them(psops) from polyspace-config. And so 20x polyspace-code-provers are run:
polyspace-code-prover -options-file c:\xxx\PolyspaceProjects\VS_Project_Y_exe.psopts -options-file "C:\xxx\PolyspaceProjects\BugFinderOptions.psops" -results-dir CodeProverResults_Y_exe
The BugFinderOptions.psops contains only: (for simplicity), this is used for both BugFinder and CodeProver.
-checkers all
Hi,
First, the resolution. You can add the option -main-generator in your options file BugFinderOptions.psops and the error will not happen. The option applies to Code Prover only but it should simply be ignored in the Bug Finder analysis, so you can continue to reuse the same options file.
Now, more about why this might be happening. It is related to your use of -module in the polyspace-configure run. It is probable that one of the Visual Studio projects in the solution leads to a shared library and not an executable. In this case, the project itself would not contain a main function.
If you check your Visual Studio solution (for instance, in VS2019, right-click a project in the Solution Explorer and select Properties), for a library, you will see something like this:

You see that the Configuration Type for zlib is Dynamic Library (.dll). Now, if I used polyspace-configure with -module on the above solution, a separate options file is created solely for zlib. Since zlib is a library that is not meant to execute on its own, it will not have a main function.
It is possible that you have a situation like this. Without exactly going through your solution, it is difficult to say more (you can always contact MathWorks Technical Support to have them diagnose the issue further).
But the workaround is simple: just use -main-generator in the options file. For cases like these where the analysis runs on files, none of which have a main, a main will be generated for you. See more about this option in -main-generator.
Looks like the complete option line to add:
-main-generator -main-generator-calls all
Thank you.
Yes, sorry. Looks like the -main-generator will force you to add the other option.
It might be better to add -main-generator-calls unused so that only functions that are not called anywhere in the project get called by the generated main. This is in fact the default in the Polyspace user interface.
I spoke too soon on the other:
"Command line error: No functions available that are out of class scope to call with -main-generator-calls option."
This comes about for both cases:
-main-generator-calls (unused or all)
Sorry again. I forgot this was C++.
Can you try -class-analyzer all -class-analyzer-calls unused?
The -main-generator-calls is all that is needed in C. But in C++, it looks only at functions defined outside a class scope. See more about the options in -class-analyzer and -class-analyzer-calls.
Ran Polyspace-code-prover on a couple projects that had returned the error prior... now it no longer puts out that error message. Thank you.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Bug Finder Analysis on Clusters についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
