我正在尝试构建 Fortran 程序,但收到有关未定义引用或未解析的外部符号的错误。我看到了有关这些错误的另一个问题,但那里的答案大多特定于 C++。
使用 Fortran 编写时出现这些错误的常见原因是什么?如何修复/预防它们?
这是构建 Fortran 程序时出现的一系列错误的典型问题。如果您被推荐到这里,或者您的问题作为与此问题重复的问题而被关闭,您可能需要阅读几个答案中的一个或多个。从这个答案开始,它充当所提供解决方案的目录。
fortran linker-errors unresolved-external undefined-reference
我想要引用对象方法的调用。这在 C++ 中可能吗?我应该搜索的技术名称是什么?我们可以提供一些具有预定值的参数吗?
以下代码突出显示了我想要使用的内容
struct Foo {
void barNoArgs();
void barMultArgs(int, float, bool);
};
Foo f;
auto& refToBarNoArgs = f.barNoArgs;
refToBarNoArgs(); // should call f.barNoArgs()
auto& refToBarMultArgs = f.barMultArgs(?, 3.14f, ?);
refToBarNoArgs(42, true); // should call f.barMultArgs(42, 3.14f, true)
Run Code Online (Sandbox Code Playgroud) 我想循环临时对的数组(指定尽可能少的类型)
for (const auto [x, y] : {{1, 1.0}, {2, 1.1}, {3, 1.2}}) {
// ...
}
Run Code Online (Sandbox Code Playgroud)
那可能吗?(我可以自由使用 gcc 11.2 中实现的任何 C++ 标准)
目前我正在使用maps 的解决方法,它非常冗长
for (const auto [x, y] : std::map<int, double>{{1, 1.0}, {2, 1.1}, {3, 1.2}}) {
// ...
}
Run Code Online (Sandbox Code Playgroud) 我使用 python scipy 库来获取 ppf 值。我正在尝试在 C++ 中计算 ppf,而不使用 python。我在网上查了很多文章,但没有找到一篇。任何人都可以帮我获得 C++ 中的 ppf 吗?
在Python中:
>>> from scipy.stats import t
>>> t.ppf(0.75,29)
0.6830438592467807
Run Code Online (Sandbox Code Playgroud)
同样,在 c++ 中,我想要一个函数传递两个变量 (0.75,29) 并返回 ppf 值 0.6830438592467808 。
我想在我自己的使用 CMake 的项目中使用uWebSockets 。
对我来说有两个问题:
如果我能让它与 CMake 一起工作,即使没有反映项目的所有可能性,我也会很高兴,例如构建示例或链接可选依赖项,如uSockets的 boost asio (其依赖项之一)。
是否可以通过 CMake 的 FetchContent 获取库?请注意,uWebSockets 将其依赖项 uSocket 设置为 git 子模块。
与其在 CMake 中重写整个 Makefile,而只是从 CMake 中调用 make,这是否有意义?
关于柯南:它抛出一个错误,我也不确定如何修复(在 Linux 上找不到 MSBuild python 包?):
ERROR: Package 'usockets/0.8.5' not resolved: usockets/0.8.5: Cannot load recipe.
Error loading conanfile at '/home/<USER>/.conan2/p/usock995f8272b80d4/e/conanfile.py': Unable to load conanfile in /home/<USER>/.conan2/p/usock995f8272b80d4/e/conanfile.py
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed …Run Code Online (Sandbox Code Playgroud) c++ ×4
cmake ×1
conan ×1
distribution ×1
for-loop ×1
fortran ×1
makefile ×1
python ×1
scipy ×1
statistics ×1
temporary ×1
uwebsockets ×1