Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build #7

Open
AAlon opened this issue Apr 17, 2019 · 4 comments
Open

Unable to build #7

AAlon opened this issue Apr 17, 2019 · 4 comments

Comments

@AAlon
Copy link

AAlon commented Apr 17, 2019

Hi,
When trying to build I'm getting all sorts of errors that mostly stem from std=c99 (instead of gnu99), it seems:

./example/roundtrip/roundtrip.c: In function ‘main’:
./example/roundtrip/roundtrip.c:130:5: warning: implicit declaration of function ‘srandom’; did you mean ‘srand’? [-Wimplicit-function-declaration]
     srandom(time(NULL) + getpid());
     ^~~~~~~
     srand
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./example/platform/zhe-util.c -o gen/zhe-util.o
./example/platform/zhe-util.c: In function ‘init_rnd_gen’:
./example/platform/zhe-util.c:29:5: warning: implicit declaration of function ‘srandom’; did you mean ‘srand’? [-Wimplicit-function-declaration]
     srandom(time(NULL) + getpid());
     ^~~~~~~
     srand
./example/platform/zhe-util.c: In function ‘cfg_handle_addrs’:
./example/platform/zhe-util.c:168:11: warning: implicit declaration of function ‘strdup’; did you mean ‘strcmp’? [-Wimplicit-function-declaration]
     str = strdup(mcgroups_join_str);
           ^~~~~~
           strcmp
./example/platform/zhe-util.c:168:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     str = strdup(mcgroups_join_str);
         ^
./example/platform/zhe-util.c:185:9: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     str = strdup(mconduit_dstaddrs_str);
         ^
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./src/zhe-bitset.c -o gen/zhe-bitset.o
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./src/zhe-icgcb.c -o gen/zhe-icgcb.o
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./src/zhe.c -o gen/zhe.o
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./src/zhe-uri.c -o gen/zhe-uri.o
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./src/zhe-unpack.c -o gen/zhe-unpack.o
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./src/zhe-pack.c -o gen/zhe-pack.o
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./src/zhe-uristore.c -o gen/zhe-uristore.o
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./src/zhe-pubsub.c -o gen/zhe-pubsub.o
cc   -std=c99 -pedantic -g -Wall -I./src -I./example/platform -I./example/configs/p2p -I./example/throughput -I./example/roundtrip -c ./example/platform/platform-udp.c -o gen/platform-udp.o
./example/platform/platform-udp.c: In function ‘zhe_platform_trace’:
./example/platform/platform-udp.c:60:5: warning: implicit declaration of function ‘flockfile’; did you mean ‘_IO_flockfile’? [-Wimplicit-function-declaration]
     flockfile(stdout);
     ^~~~~~~~~
     _IO_flockfile
./example/platform/platform-udp.c:64:5: warning: implicit declaration of function ‘funlockfile’; did you mean ‘_IO_funlockfile’? [-Wimplicit-function-declaration]
     funlockfile(stdout);
     ^~~~~~~~~~~
     _IO_funlockfile
./example/platform/platform-udp.c: In function ‘zhe_platform_join’:
./example/platform/platform-udp.c:266:20: error: storage size of ‘mreq’ isn’t known
     struct ip_mreq mreq;
                    ^~~~
./example/platform/platform-udp.c:266:20: warning: unused variable ‘mreq’ [-Wunused-variable]
./example/platform/platform-udp.c: In function ‘zhe_platform_send’:
./example/platform/platform-udp.c:300:33: warning: implicit declaration of function ‘random’; did you mean ‘rand’? [-Wimplicit-function-declaration]
     if (udp->randomthreshold && random() < udp->randomthreshold) {
                                 ^~~~~~
                                 rand
makefile:51: recipe for target 'gen/pla

I didn't find any build instructions either; I'd appreciate your help.

@eboasson
Copy link
Contributor

Hi @AAlon,

Interesting! It is not like there is absolutely zero documentation (there isn't much, but there is some at least), so who'd imagined I'd forget to add

git clone https://github.com/atolab/zhe ; cd zhe ; mkdir build ; cd build ; cmake .. ; make

to the README 🤔. I imagine it wouldn't have helped, it seems to me you probably did just that and yet ran into problems.

To me the messages you got don't look so much like a c99 versus gnu99 issue, but more like a platform that requires some additional header files (and perhaps macro definitions, like _GNU_SOURCE, __EXTENSIONS__, _POSIX_C_SOURCE=199506L …). Just for good measure, I verified that works fine on macOS and Fedora 29 (and, IIRC, a few variants more).

What is important is that there should be zero issues compiling the files in src: those were all written with the intent to be strictly conforming C99 code. Now writing "strictly conforming" C is pretty much impossible in practice, but there should certainly not be a problem compiling them. Of course that also means everything that is remotely platform-specific has to be defined elsewhere.

Hence the minimalistic platform abstraction, for which there is some implementation inside the example/platform directory. The examples themselves also assume some things. That seems to be where your problems lie.

Just adding a #include or two there will probably solve it, and otherwise some of the stuff can simply be skipped (there is no need to call flockfile) and one of the calls to random can be excluded just by changing the definition of SIMUL_PACKET_LOSS at the top of the file and the other use of it is simply to generate a unique identifier. Indeed, you could even replace random/srandom by rand/srand despite it being a devastingly bad random generator, it is probably still good enough for the purpose here.

If strdup is not available, it is just a trivial wrapper around strlen, malloc and strcpy, so that should be manageable as well.

Therefore the only really interesting one is struct ip_mreq. As I don't know what platform you are trying to compile it on, I don't have any suggestion where it is defined ... even if it isn't you can still switch to using TCP instead of UDP and avoid needing it!

@AAlon
Copy link
Author

AAlon commented Apr 17, 2019

Thanks for the thorough response, I think you're right and the suggestions given would get me really close to having a successful build. However at this time I'm preoccupied with other things and cannot spend time on getting it to work.
My platform is nothing special - Ubuntu Bionic on amd64 - and so I had hoped it would work out of the box.

@seimonw
Copy link

seimonw commented Apr 18, 2019

Just an observation - I think @AAlon had been trying to run the makefile in the root of the project rather than using cmake.

@eboasson
Copy link
Contributor

Interesting observation. Yes, that makefile in the root of the project is my quick hack for building on any random platform and sometimes sees some modifications.

My platform is nothing special - Ubuntu Bionic on amd64 - and so I had hoped it would work out of the box.

Yes, that's completely standard and it really should work out-of-the-box on it.

I don't have one of those available right now, but if that's the platform I would expect just dropping the "-std=c99" might well do the trick. Curious that they appear to have chosen to let the c99/gnu99 difference have such an effect on what library functions are visible. I'll see if I can get a VM with Ubuntu Bionic up and running tomorrow to sort it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants