raburton / evoplus_cid

Samsung Evo Plus CID changer
GNU General Public License v3.0
158 stars 82 forks source link

Compilation error on Linux #17

Open FilipLaurentiu opened 2 months ago

FilipLaurentiu commented 2 months ago

Any idea why I got this error ? I am not that good with C.. :disappointed:

➜  evoplus_cid git:(master) gcc ./jni/evoplus_cid.c -o evoplus_cid                                                               git:(master|) 
./jni/evoplus_cid.c: In function ‘parse_serial’:
./jni/evoplus_cid.c:107:14: error: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
  107 |         if ((strlen(str) > 2) && (str[0] == '0') &&
      |              ^~~~~~
./jni/evoplus_cid.c:6:1: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
    5 | #include "mmc.h"
  +++ |+#include <string.h>
    6 | 
./jni/evoplus_cid.c:107:14: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
  107 |         if ((strlen(str) > 2) && (str[0] == '0') &&
      |              ^~~~~~
./jni/evoplus_cid.c:107:14: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
./jni/evoplus_cid.c:109:23: error: implicit declaration of function ‘strtol’ [-Wimplicit-function-declaration]
  109 |                 val = strtol(str, NULL, 16);
      |                       ^~~~~~
./jni/evoplus_cid.c: In function ‘main’:
./jni/evoplus_cid.c:135:15: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch]
  135 |         len = strlen(argv[2]);
      |               ^~~~~~
./jni/evoplus_cid.c:135:15: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
./jni/evoplus_cid.c:179:9: error: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration]
  179 |         close(fd);
      |         ^~~~~
      |         pclose
raburton commented 2 months ago

Your compiler has stricter options set than I had when I wrote this, and wants to see these standard c functions defined. Try adding the suggested include (string.h) to the top of the file.

On Thu, 2 May 2024, 1:47 pm Filip Laurentiu, @.***> wrote:

Any idea why I got this error ? I am not that good with C.. 😞

➜ evoplus_cid git:(master) gcc ./jni/evoplus_cid.c -o evoplus_cid git:(master|) ./jni/evoplus_cid.c: In function ‘parse_serial’: ./jni/evoplus_cid.c:107:14: error: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration] 107 | if ((strlen(str) > 2) && (str[0] == '0') && | ^~ ./jni/evoplus_cid.c:6:1: note: include ‘’ or provide a declaration of ‘strlen’ 5 | #include "mmc.h" +++ |+#include 6 | ./jni/evoplus_cid.c:107:14: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch] 107 | if ((strlen(str) > 2) && (str[0] == '0') && | ^~ ./jni/evoplus_cid.c:107:14: note: include ‘’ or provide a declaration of ‘strlen’ ./jni/evoplus_cid.c:109:23: error: implicit declaration of function ‘strtol’ [-Wimplicit-function-declaration] 109 | val = strtol(str, NULL, 16); | ^~ ./jni/evoplus_cid.c: In function ‘main’: ./jni/evoplus_cid.c:135:15: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch] 135 | len = strlen(argv[2]); | ^~ ./jni/evoplus_cid.c:135:15: note: include ‘’ or provide a declaration of ‘strlen’ ./jni/evoplus_cid.c:179:9: error: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration] 179 | close(fd); | ^~~~~ | pclose

— Reply to this email directly, view it on GitHub https://github.com/raburton/evoplus_cid/issues/17, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADJ3B47U53IH3YMYVCAOO3ZAIYXRAVCNFSM6AAAAABHDU5RCCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3TKNBVG43DMNY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

FilipLaurentiu commented 2 months ago

Your compiler has stricter options set than I had when I wrote this, and wants to see these standard c functions defined. Try adding the suggested include (string.h) to the top of the file. On Thu, 2 May 2024, 1:47 pm Filip Laurentiu, @.> wrote: Any idea why I got this error ? I am not that good with C.. 😞 ➜ evoplus_cid git:(master) gcc ./jni/evoplus_cid.c -o evoplus_cid git:(master|) ./jni/evoplus_cid.c: In function ‘parse_serial’: ./jni/evoplus_cid.c:107:14: error: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration] 107 | if ((strlen(str) > 2) && (str[0] == '0') && | ^~ ./jni/evoplus_cid.c:6:1: note: include ‘’ or provide a declaration of ‘strlen’ 5 | #include "mmc.h" +++ |+#include 6 | ./jni/evoplus_cid.c:107:14: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch] 107 | if ((strlen(str) > 2) && (str[0] == '0') && | ^~ ./jni/evoplus_cid.c:107:14: note: include ‘’ or provide a declaration of ‘strlen’ ./jni/evoplus_cid.c:109:23: error: implicit declaration of function ‘strtol’ [-Wimplicit-function-declaration] 109 | val = strtol(str, NULL, 16); | ^~ ./jni/evoplus_cid.c: In function ‘main’: ./jni/evoplus_cid.c:135:15: warning: incompatible implicit declaration of built-in function ‘strlen’ [-Wbuiltin-declaration-mismatch] 135 | len = strlen(argv[2]); | ^~ ./jni/evoplus_cid.c:135:15: note: include ‘’ or provide a declaration of ‘strlen’ ./jni/evoplus_cid.c:179:9: error: implicit declaration of function ‘close’; did you mean ‘pclose’? [-Wimplicit-function-declaration] 179 | close(fd); | ^~~~~ | pclose — Reply to this email directly, view it on GitHub <#17>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADJ3B47U53IH3YMYVCAOO3ZAIYXRAVCNFSM6AAAAABHDU5RCCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3TKNBVG43DMNY . You are receiving this because you are subscribed to this thread.Message ID: @.>

I made the changes but when I tried to make a PR to the repo I saw that there is already another PR fixing the same issue https://github.com/raburton/evoplus_cid/pull/8/commits/00e49cb2545f1e5e257217120bea2f1e0095a9b6

raburton commented 2 months ago

Yes, I'd forgotten about that. The PR wasn't accepted because of unrelated changes to the code, and being untested on Android build system.

FilipLaurentiu commented 2 months ago

Yes, I'd forgotten about that. The PR wasn't accepted because of unrelated changes to the code, and being untested on Android build system.

I made another one :)

raburton commented 2 months ago

Is it tested and building fine with android sdk?

FilipLaurentiu commented 2 months ago

Is it tested and building fine with android sdk?

no really..I tested only with linux. I can't test with Android SDK

raburton commented 2 months ago

That was the other half of the reason for not accepting the previous PR. This code is intended for Android (although also works on Linux) so needs to remain compatible with Android. It probably will still build fine, but I no longer have an Android build system to test with.