Recent

Author Topic: Define not found. Android - ARMv7.  (Read 3635 times)

Seenkao

  • Hero Member
  • *****
  • Posts: 613
    • New ZenGL.
Define not found. Android - ARMv7.
« on: June 21, 2023, 09:31:26 am »
  Мне надо определить в конфигурации проекта архитектуру ARMv7a. Или хотя бы ARMv7. Но для Android нет определений данной конфигурации. Самая последняя конфигурация это CPUARMV5T.

  Я могу через какие-то другие конфигурации это реализовать?

Google translate:
  I need to define the ARMv7a architecture in the project configuration. Or at least ARMv7. But for Android, there are no definitions for this configuration. The latest configuration is CPUARMV5T.

   Can I implement this through some other configurations?

example:
Code: Pascal  [Select][+][-]
  1. {$IfDef CPUi386}
  2.   ...
  3.   z := z + 1;
  4.   ...
  5. {$EndIf}
  6. {$IfDef CPUARMV7A}    // does not exist
  7.   ...
  8.   z := z - 4;
  9.   ...
  10. {$EndIf}
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Laksen

  • Hero Member
  • *****
  • Posts: 785
    • J-Software
Re: Define not found. Android - ARMv7.
« Reply #1 on: June 21, 2023, 01:05:39 pm »
What do you mean with configurations for that? CPUARMV7A has been supported for years

Josh

  • Hero Member
  • *****
  • Posts: 1344
Re: Define not found. Android - ARMv7.
« Reply #2 on: June 21, 2023, 02:24:32 pm »
If you have multiple build options for you project then you can create a build for your CPU
then in project option/custom defines create a new define called YourCPU

then you can use
{$ifdef YourCPU}
code only compiled for this define
{$endif}


The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Seenkao

  • Hero Member
  • *****
  • Posts: 613
    • New ZenGL.
Re: Define not found. Android - ARMv7.
« Reply #3 on: June 21, 2023, 06:37:34 pm »
Мне надо в программе с помощью IfDef (Define) определить тип архитектуры. Если вы попытаетесь использовать код который я написал, он не будет работать для архитектуры V7A для Android.

Как я могу определить что программист использует архитектуру V7A для Android?

Josh, благодарю! Это, видимо самое подходящее для меня решение. А есть возможность определить define программно? Например в конфигурации проекта.

Google translate:
I need to use IfDef (Define) to define the type of architecture in the program. If you try to use the code I wrote, it will not work for the V7A architecture for Android.

How can I tell if a programmer is using the V7A architecture for Android?

Josh, thank you! This seems to be the best solution for me. Is it possible to define define programmatically? For example in the project configuration.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Josh

  • Hero Member
  • *****
  • Posts: 1344
Re: Define not found. Android - ARMv7.
« Reply #4 on: June 21, 2023, 08:00:08 pm »
Yes you can create define programmatically, but remember its a compiled not interpreted.

{$define CPUARMv7}

this would need to be in early on in unit, or in the lpr file.

you can do things like
{$ifdef CPUARMv7}
{$Define OPTION_1}
{$EndIf}

{$ifdef CPUARMv8}
{$Define OPTION_2}
{$EndIf}

{$ifdef CPUARMv9}
{$Define OPTION_3}
{$EndIf}


remember only code with in an active define block will be compiled.

if its to do with offsets or variable definitions etc, you could do something like :-

pseudo code, not tested

Code: Pascal  [Select][+][-]
  1. procedure setmydefaults;
  2. var opt_t:integer=0; // default value
  3.  
  4. function set_integer(ADef,AVal1,AVal2,AVal3:Integer):Integer;
  5. begin
  6.    result:=ADef;
  7.    Case opt_t of
  8.       0:Result:=ADef;
  9.       1:Result:=AVal1;
  10.       2:Result:=AVal2;
  11.       3:Result:=AVal3;
  12.     end;
  13. end;
  14.  
  15. begin
  16.   // define one of these in code before calling setmydefaults to use the option
  17.   //  however you could also set this value before setting your defaullts, ie
  18.   //  from params of commandline, or by using code that detects whatever criteria is
  19.   // this is no good for code that uses API calls for a platform.
  20.   {$ifdef option_1}opt_t:=1;{$endif}
  21.   {$ifdef option_2}opt_t:=2;{$endif}
  22.   {$ifdef option_3}opt_t:=3;{$endif}
  23.  
  24.   oneofmyintegers:=set_integer(0,2,4,8);
  25.    
  26. end;
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Laksen

  • Hero Member
  • *****
  • Posts: 785
    • J-Software
Re: Define not found. Android - ARMv7.
« Reply #5 on: June 21, 2023, 08:30:05 pm »
Try to run
Code: Pascal  [Select][+][-]
  1. fpc -Parm -Cparmv7a -va

Somewhere it should show:
Code: [Select]
[0.000] Macro defined: CPUARMV7A

Josh

  • Hero Member
  • *****
  • Posts: 1344
Re: Define not found. Android - ARMv7.
« Reply #6 on: June 21, 2023, 08:31:35 pm »
i dont use android, but curios to see with the following, if eith Android32 or Android64 gets defined
Code: Pascal  [Select][+][-]
  1. {$IFDEF ANDROID}
  2. {$ifdef CPU32}
  3. {$Define Android32}
  4. {$endif}
  5. {$ifdef CPU64}
  6. {$Define Android64}
  7. {$endif}
  8. {$Endif}  
         
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Seenkao

  • Hero Member
  • *****
  • Posts: 613
    • New ZenGL.
Re: Define not found. Android - ARMv7.
« Reply #7 on: June 21, 2023, 08:42:51 pm »
Laksen, ты не хочешь понять, что данного определения нет для Android.

Josh, да, я вспомнил. Это стандартные определения... Но это получается что сам пользователь должен следить за тем, под какой процессор идёт разработка.
Есть над чем подумать.  :)

Google translate:
Laksen, you do not want to understand that this definition does not exist for Android.

Josh, yes, I remember. These are standard definitions... But it turns out that the user himself must keep track of which processor is being developed.
There is something to think about. :)
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Josh

  • Hero Member
  • *****
  • Posts: 1344
Re: Define not found. Android - ARMv7.
« Reply #8 on: June 21, 2023, 09:36:57 pm »
Hi Seenkao,

Just curious as to the type of App are you develping?

Excuse the text below, as am sure you are aware of it, but other people reading in future may not.

Normally the 'user' is not aware or even care about the cpu being used.
The developer will generally create various binaries for each platform the app supports, nowadays when you deploy the app as a package it will contain the binaries for which ever cpu(s) you support, to the user when installing the package the os will choose the app in the package that is for the cpu its running on. With Windows/Mac the installer will contain both X86-64 and Aarch64/M1 executables as a combined installer.

Each binary will be optimized for the architecture at compile time.

As the developer the ifdef are used generally to set any specific vars that defer between os/widgetset  builds for your app to work/display properly, and to allow you to have a std function that return a value for the specific os.
ie pseudo code
Code: Pascal  [Select][+][-]
  1. function getmydocslocation:ansistring;
  2. begin
  3.   {$ifdef windows}
  4.   result:=use windows api call to get value;
  5.   {$endif}
  6.   {$ifdef darwin}
  7.   result:=use macos apicall to get value;
  8.   {$endif}
  9. end;
  10.  

This is indeed what a lot of the lcl does for its controls, as most are wrappers around the os's native widgets or indeed specific widgetsets gtk2,3,qt etc.

I have myself a unit called my_standard_functions, which has obviously my own standard routines, but also contains other functions the set/get variables needed for other code, theses functions have various ifdef and nested ifdef to set get values. But makes the rest of my code much easier to read as other units do not contain ifdef, and if something changes i just alter my_standard_functions unit, then any app i have created i can just recompile as it will compile using the moded standard_functions unit.
« Last Edit: June 21, 2023, 09:39:25 pm by Josh »
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

Seenkao

  • Hero Member
  • *****
  • Posts: 613
    • New ZenGL.
Re: Define not found. Android - ARMv7.
« Reply #9 on: June 21, 2023, 10:14:23 pm »
Josh, ZenGL.  :)
https://forum.lazarus.freepascal.org/index.php/topic,49143.0.html

Я думал у меня отображается информация... но по непонятной причине все ссылки обнулились.
Сейчас скомпилировал многие библиотеки для архитектур v7a и v8a, и отделить v7a не могу от более старых архитектур. Это вызовет проблемы у конечного пользователя ZenGL. Ведь пользователь будет создавать свои приложения. А указав нужную ему архитектуру, код который не должен работать с данной архитектурой может сработать. Вот и ищу метод предотвратить подобные проблемы.  :(

Google translate:
I thought I was displaying information ... but for some unknown reason, all links were reset to zero.
Now I have compiled many libraries for v7a and v8a architectures, and I cannot separate v7a from older architectures. This will cause problems for the end user of ZenGL. After all, the user will create their own applications. And by specifying the architecture he needs, the code that should not work with this architecture can work. So I'm looking for a way to prevent such problems. :(
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Laksen

  • Hero Member
  • *****
  • Posts: 785
    • J-Software
Re: Define not found. Android - ARMv7.
« Reply #10 on: June 22, 2023, 12:31:19 am »
Laksen, you do not want to understand that this definition does not exist for Android.

Please enlighten me why that should not be the case for the android target, compared to all the other targets?
This code has been the same for essentially 13 years

https://gitlab.com/freepascal.org/fpc/source/-/blob/826f208e4549fe2c94962ab23f8f9d995fae4d92/compiler/options.pas#L3345

Which compiler version are you using?

Seenkao

  • Hero Member
  • *****
  • Posts: 613
    • New ZenGL.
Re: Define not found. Android - ARMv7.
« Reply #11 on: June 22, 2023, 01:23:30 am »
Laksen, вы пробовали проверить код, в первоначальном посте для архитектуры Android-ARMv7a?

Как я могу вам ответить на ваш вопрос, если вы не хотите проверять код который я скинул, с той архитектурой и операционной системой, что я указал?
В файле fpcdefines.xml нет указаний DEFINE для OS-Android + CPU-ARMv7a.

Google translate:
Laksen, have you tried to check the code in the original post for architecture Android-ARMv7a?

How can I answer your question if you do not want to check the code that I threw off with the architecture and operating system that I indicated?
The file fpcdefines.xml does not contain DEFINE for OS-Android + CPU-ARMv7a.

I use Linux-Debian
Free Pascal Compiler version 3.2.2-rrelease_3_2_2-0-g0d122c4953 [2023/02/03] for x86_64

Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

 

TinyPortal © 2005-2018