File tree 5 files changed +72
-12
lines changed
5 files changed +72
-12
lines changed Original file line number Diff line number Diff line change
1
+ C++ Hello World
2
+ ================
3
+
4
+ Compile C++ code:
5
+
6
+ ``` sh
7
+ gcc main.cpp -lstdc++ -o app.exe
8
+ ```
9
+
10
+ Run with ops:
11
+
12
+ ``` sh
13
+ ops run app.exe
14
+ ```
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ C++ Hello World
2
+ ================
3
+
4
+ Depending on your libc version and your distro of choice you'll want to
5
+ include libresolv (you might not have to do this on newer versions):
6
+
7
+ ``` sh
8
+ cc main.cpp -o main
9
+ ```
10
+
11
+ config.json:
12
+ ``` sh
13
+ {
14
+ " Files" : [" /usr/lib/x86_64-linux-gnu/libresolv.so.2" ]
15
+ }
16
+ ```
17
+
18
+ If you're unsure you can do a
19
+
20
+ ```
21
+ ops run --trace main &>/tmp/out
22
+ ```
23
+
24
+ and grep for library load failures. Most OPS packages auto-include this
25
+ for interpreted languages and other newer compiled languages deal with
26
+ this differently.
27
+
28
+ ```
29
+ ops run -c config.json main
30
+ ```
Original file line number Diff line number Diff line change
1
+ #include < sys/types.h>
2
+ #include < stdlib.h>
3
+ #include < sys/socket.h>
4
+ #include < netinet/in.h>
5
+ #include < arpa/inet.h>
6
+ #include < netdb.h>
7
+ #include < stdio.h>
8
+
9
+ int main (int argc, char *argv[])
10
+ {
11
+
12
+ struct hostent *hp;
13
+ struct in_addr ip_addr;
14
+
15
+ const char *host = " dns.google" ;
16
+
17
+ hp = gethostbyname (host);
18
+ if (!hp) {
19
+ printf (" was not resolved\n " );
20
+ }
21
+
22
+ ip_addr = *(struct in_addr *)(hp->h_addr );
23
+ printf (" Hostname: dns.google, was resolved to: %s\n " ,
24
+ inet_ntoa (ip_addr));
25
+
26
+ exit (EXIT_SUCCESS);
27
+
28
+ }
Original file line number Diff line number Diff line change 1
1
C++ Hello World
2
2
================
3
-
4
- Compile C++ code:
5
-
6
- ``` sh
7
- gcc main.cpp -lstdc++ -o app.exe
8
- ```
9
-
10
- Run with ops:
11
-
12
- ``` sh
13
- ops run app.exe
14
- ```
You can’t perform that action at this time.
0 commit comments