gcc - error: no acceptable C compiler found in $PATH

511

Solution 1

GCC itself is written in C. Thus, in order to install it, you need a C compiler. This is a catch-22. You're not missing anything. In fact, there is a rather famous Ken Thompson essay, “Reflections on Trusting Trust” reflecting upon a related aspect.

You need to get a C compiler from somewhere. Whoever built your custom distribution surely had one, as you can't build a Linux kernel without it either. They ought to make it available somewhere.

Other than that, you'll have to cross-compile gcc (and binutils, and C library headers, etc.) from a distro where you can install a compiler. This is how someone builds the a distro for a new platform. It's also possible that if your platform is embedded, no one expects you to run gcc on the device itself, and instead they expect you to cross-compile any software you need for the device. In that case, your embedded distro should provide the cross-compiler to use.

Solution 2

I had this exact issue while working with a Ubuntu subsystem within Windows 10 and solved it by doing:

sudo apt-get update 
sudo apt install build-essential

Alternatively, the second command could be more specific:

sudo apt install gcc
Share:
511

Related videos on Youtube

bucky
Author by

bucky

Updated on September 18, 2022

Comments

  • bucky
    bucky over 1 year

    So this is a fragment class . I am trying to add some items to listview using baseadaptor. I am a beginner so i followed this question. How to customize listview using baseadapter But now i am getting setcontentview error (Couldn't resolve error) at line no. 72 and inner class error at 147. So please help me in fixing it. package layout;

    import android.content.Context;
    import android.net.Uri;
    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.ImageView;
    import android.widget.ListView;
    import android.widget.TextView;
    
    import com.buckydroid.app.droidcpu.R;
    
    
    public class ussd extends Fragment {
        ListView l1;
        String[] t1={"ussd1","ussd2"};
        String[] d1={"le1","ln2"};
        private View myfragment;
        int[] i1 ={R.drawable.ic_launcher,R.drawable.ic_launcher};
        // TODO: Rename parameter arguments, choose names that match
        // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
        private static final String ARG_PARAM1 = "param1";
        private static final String ARG_PARAM2 = "param2";
    
        // TODO: Rename and change types of parameters
        private String mParam1;
        private String mParam2;
    
        private dataListAdapter.OnFragmentInteractionListener mListener;
    
        /**
         * Use this factory method to create a new instance of
         * this fragment using the provided parameters.
         *
         * @param param1 Parameter 1.
         * @param param2 Parameter 2.
         * @return A new instance of fragment ussd.
         */
        // TODO: Rename and change types and number of parameters
        public static ussd newInstance(String param1, String param2) {
            ussd fragment = new ussd();
            Bundle args = new Bundle();
            args.putString(ARG_PARAM1, param1);
            args.putString(ARG_PARAM2, param2);
            fragment.setArguments(args);
            return fragment;
        }
        public ussd() {
            // Required empty public constructor
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            if (getArguments() != null) {
                mParam1 = getArguments().getString(ARG_PARAM1);
                mParam2 = getArguments().getString(ARG_PARAM2);
            }
        }
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            // Inflate the layout for this fragment
            return inflater.inflate(R.layout.fragment_ussd, container, false);
            myfragment =  inflater.inflate(R.layout.fragment_ussd, container, false);
            //getting error at thus part "cannot resolve setcontentview"
            setContentView(R.layout.fragment_ussd);
            l1=(ListView)myfragment.findViewById(R.id.listView);
            l1.setAdapter(new dataListAdapter(t1,d1,i1));
        }
    
        class dataListAdapter extends BaseAdapter {
            String[] Title, Detail;
            int[] imge;
    
            dataListAdapter() {
                Title = null;
                Detail = null;
                imge=null;
            }
    
            public dataListAdapter(String[] text, String[] text1,int[] text3) {
                Title = text;
                Detail = text1;
                imge = text3;
    
            }
    
            public int getCount() {
                // TODO Auto-generated method stub
                return Title.length;
            }
    
            public Object getItem(int arg0) {
                // TODO Auto-generated method stub
                return null;
            }
    
            public long getItemId(int position) {
                // TODO Auto-generated method stub
                return position;
            }
    
            public View getView(int position, View convertView, ViewGroup parent) {
    
                LayoutInflater inflater = getLayoutInflater(Bundle.EMPTY);
                View row;
                //getting error at this part too "unconditional layout inflation from view adaptor
                row = inflater.inflate(R.layout.listing, parent, false);
                TextView title, detail;
                ImageView i1;
                title = (TextView) row.findViewById(R.id.title);
                detail = (TextView) row.findViewById(R.id.detail);
                i1=(ImageView)row.findViewById(R.id.img);
                title.setText(Title[position]);
                detail.setText(Detail[position]);
                i1.setImageResource(imge[position]);
    
                return (row);
        }
    
        // TODO: Rename method, update argument and hook method into UI event
        public void onButtonPressed(Uri uri) {
            if (mListener != null) {
                mListener.onFragmentInteraction(uri);
            }
        }
    
    
    
    
        /**
         * This interface must be implemented by activities that contain this
         * fragment to allow an interaction in this fragment to be communicated
         * to the activity and potentially other fragments contained in that
         * activity.
         * <p>
         * See the Android Training lesson <a href=
         * "http://developer.android.com/training/basics/fragments/communicating.html"
         * >Communicating with Other Fragments</a> for more information.
         */
        public interface OnFragmentInteractionListener {
            // TODO: Update argument type and name
            void onFragmentInteraction(Uri uri);
        }
    
    
    
    
    
    
            }
        }
    
    • SripadRaj
      SripadRaj almost 8 years
      Remove setContentView(R.layout.fragment_ussd); in your onCreateView(). You dont need it in a fragment
    • ρяσѕρєя K
      ρяσѕρєя K almost 8 years
      Why not getting unreachable code after return statement warning
    • Pankaj Goyal
      Pankaj Goyal almost 7 years
      The source code to GCC still needs to be compiled by something, like yacc or some other compiler. Otherwise you're asking how a dictionary can possibly make any sense, what with it using words to define words that are themselves defined by words which are all defined within the dictionary that you can't use if you don't know any words to begin with.
    • rici
      rici almost 7 years
      @dopeghoti: yacc is not a c compiler
    • Pankaj Goyal
      Pankaj Goyal almost 7 years
      Could have sworn it was Yet Another C Compiler. I stand corrected.
  • bucky
    bucky almost 8 years
    Thanx it fixed @SripadRaj but what about the 2nd error..
  • bucky
    bucky almost 8 years
    inner class cannot have static declaration at the line no. 148
  • SripadRaj
    SripadRaj almost 8 years
    what is line no. 148?
  • Gerald Murphy
    Gerald Murphy almost 7 years
    Interesting...I am using a Raspberry Pi, so maybe I will need to cross-compile. I do not have experience with cross-compiling so I will have to look into that. Any idea which dir on my distro a C compiler might be located? Also if I understand your comment correctly, since the reason I wanted to install GCC was so I could use it during the installation of a different piece of software I could just forget about installing GCC and use cross-compiling to install the other software that I need. Is that correct?
  • Gerald Murphy
    Gerald Murphy almost 7 years
    I am using a Yocto distribution. I don't see anything that looks like a C compiler under /usr/bin/ (I am assuming it would be called something like 'C' 'compile' or 'gcc' but I am not sure.). I will see if I can find a tar for a C compiler.