Giter VIP home page Giter VIP logo

Comments (6)

lilyanatia avatar lilyanatia commented on August 24, 2024

learn to use your compiler.
-std=c99 -lpthread -lpcre -lcrypto

or, since your libc is apparently broken unless you use -std=gnu99,
-std=gnu99 -lpthread -lpcre -lcrypto

from trip.

aeosynth avatar aeosynth commented on August 24, 2024

I'm not a c hacker, so forgive me. This would have been easier if you had a readme. Could I get the right options to compile trip-std.c by any chance?

[james@arch trip]$ cc --std=gnu99 trip-std.c
trip-std.c: In function ‘trip_search’:
trip-std.c:124:5: warning: implicit declaration of function ‘crypt’
trip-std.c:124:5: warning: passing argument 2 of ‘memcpy’ makes pointer from integer without a cast
/usr/include/string.h:44:14: note: expected ‘const void * restrict’ but argument is of type ‘int’
/tmp/ccBr4xk0.o: In function `main':
trip-std.c:(.text+0x3c8): undefined reference to `pthread_create'
/tmp/ccBr4xk0.o: In function `trip_search':
trip-std.c:(.text+0x771): undefined reference to `crypt'
collect2: ld returned 1 exit status

from trip.

lilyanatia avatar lilyanatia commented on August 24, 2024

if your system doesn't have crypt, trip-std.c won't work for you.
if you can fix that, you'll need to link it against libpthread (-lpthread).

from trip.

aeosynth avatar aeosynth commented on August 24, 2024

I can get it to compile with -std=gnu99 -lpthread -lcrypt, but it just segfaults.

[james@arch trip]$ cc trip-std.c -o trip-std -std=gnu99 -lpthread -lcrypt 
trip-std.c: In function ‘trip_search’:
trip-std.c:124:5: warning: implicit declaration of function ‘crypt’
trip-std.c:124:5: warning: passing argument 2 of ‘memcpy’ makes pointer from integer without a cast
/usr/include/string.h:44:14: note: expected ‘const void * restrict’ but argument is of type ‘int’
[james@arch trip]$ ./trip-std wat
Segmentation fault

I'm on Arch Linux btw.

from trip.

lilyanatia avatar lilyanatia commented on August 24, 2024

those warnings are because crypt isn't declared in unistd.h like it should be.
"implicit declaration" means that it's assuming it's int crypt(int), when it should be char *crypt(const char *, const char *). that's probably why you're getting a segfault.
you could try adding a declaration for crypt, but the right way to fix it would be to figure out why your unistd.h doesn't declare crypt.

from trip.

aeosynth avatar aeosynth commented on August 24, 2024

I figured it out - the declaration in unistd.h is guarded by #ifdef __USE_XOPEN; adding #define __USE_XOPEN to trip-std.c makes it work.

from trip.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.