C++ linker presentation
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "=== This build SHOULD fail with 'undefined reference' ==="
|
||||
echo ""
|
||||
g++ -std=c++17 main.cpp -o app 2>&1 || true
|
||||
echo ""
|
||||
echo "The linker cannot find a definition for add(int, int)."
|
||||
echo "Fix: provide the .cpp that defines it, or link the correct library."
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <iostream>
|
||||
|
||||
int add(int, int); // declared but never defined
|
||||
|
||||
int main() {
|
||||
std::cout << add(3, 4) << "\n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user